Graph Problem

Minimum labelled node to be removed from undirected Graph such that there is no cycle can anyone explain this??

1 Like

Suppose You have n nodes , Then There label is 1 , 2 , 3 … , n . In question you have to find node which when removed results in Acyclic graph which means if you start traversing from any node on graph you should not reach this node again in traversal.
If you get multiple answers say 2 , 5 , 7 Then choose the minimum one , i.e. 2 .

if you prefer the second example from that link node(1,5,4,2) are visited more than once…how come 4 is the answer?
can u give detailed explanaion??

Here in this example you can get Acyclic graph only if you remove 4.

Hope you Got it.

i understood the what you have explained but not able to get the implementation part from geeksforgeeks code. whats yours approach ? is it different approach from the given code?? if it is more simplify than the given code can you share your approach??