如何在Jgrapht中使用FloydWarshallShortestPaths

时间:2016-05-03 11:36:15

标签: java graph jgrapht

我想找到从节点到我图中所有其他节点的最短路径。如何使用Jgrapht中提供的FloydWarshallShortestPaths来执行此操作。

 List path =
                FloydWarshallShortestPaths.getShortestPaths(city1);

这似乎不起作用。

1 个答案:

答案 0 :(得分:0)

方法getShortestPaths不是静态的。您需要首先生成FloydWarshallShortestPaths类型的实例。

http://jgrapht.org/javadoc/org/jgrapht/alg/FloydWarshallShortestPaths.html#getShortestPaths(V)