What algorithm can I use to find the shortest path between specified node types in a graph?

后端 未结 8 1845
自闭症患者
自闭症患者 2021-02-14 12:19

This is the problem:

I have n points (p1, p2, p3, .. pn), each of them can connect to any other with a determined cost x.

Each point belongs to one of a set of p

8条回答
  •  遇见更好的自我
    2021-02-14 12:28

    1. Calculate all the pairs of shortest paths within each equivalence block.
    2. Now build a graph which has NO inter-class edges, but whose edges between classes match the shortest path within that class, leading to the specific node of another class.

    Hope this is clear.

    This solution is not particularly efficient, but clearly polynomial.

提交回复
热议问题