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
Post a Comment