c - Verify if an undirected graph has cycles -


i know question has been asked times. can't understand yet , questions old reply...

i read kahn's algorithm
dfs
plus tarjan's connected components algorithm
can't understand process make work.
i've done far initialized , feed graph.
, found shortest path vertéx b.

a simple dfs little modification do.

hint: dfs traversal of given graph. every visited vertex ‘v’, if there adjacent ‘u’ such u visited , u not parent of v, there cycle in graph.

also note: cycles detection in undirected graphs follow algorithm totally different directed graphs. cycle in directed graphs diffent.

(hope comfortable dfs).


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -