sir here my code is showing segmentation error
please correct it.
Graph implementation problem using list
@Megha2468 as one of the vertices is 4 you have to give n >=5 value.
i hope its clear if yes dont forget to mark it as resolved 
sir but why we have to do so.I was not able to understand the reason
@Megha2468 list is only contains 0 to n-1 blocks like array as you have declared it of size [n]
so you cant access values greater than eq n
ok Thanks .my code worked
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.