Find the paths between two given nodes?

前端 未结 8 2103
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 11:55

Say I have nodes connected in the below fashion, how do I arrive at the number of paths that exist between given points, and path details?

1,2 //node 1 and 2         


        
8条回答
  •  無奈伤痛
    2020-11-27 12:37

    What you're trying to do is essentially to find a path between two vertices in a (directed?) graph check out Dijkstra's algorithm if you need shortest path or write a simple recursive function if you need whatever paths exist.

提交回复
热议问题