We have k Component and given graph is forest so each component has x – 1 edges (where component is tree with x vertices )
suppose we divide vertices v into $x_{1}$ , $x_{2}$ , … , $x_{k}$ => where each $x_{i}$ denote the number of vertices in $i^{th}$ Component
$x_{1}$ + $x_{2}$ + … + $x_{k}$ = v
→ $x_{1}$ has $x_{1}$ – 1 edges (as each component is a tree)
→ $x_{2}$ has $x_{2}$ – 1 edges
so on
So total number of edges = Sum of all component edges
= ( $x_{1}$ – 1 ) + ( $x_{2}$ – 1 ) + ( $x_{3}$ – 1 ) + … + ( $x_{k}$ – 1 )
= ( $x_{1}$ + $x_{2}$ + … + $x_{k}$) – k
= v – k