algorithm - Shortest path between two given nodes in unweighted graph/tree -


i looking algorithm determine shortest path between 2 nodes in unweighted graph using adjacency matrix . know dijkstra , bellman - ford, none found specific determine shortest path between 2 given nodes.

any apreciated

one simple option run breadth-first search starting @ first node until second node found. if store parent pointers each node, can read off path first node second. moreover, runs in linear time in size of graph.

hope helps!


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -