java - 在 JGraphT 中合并图形

标签 java jgrapht

我正在使用 JGraphT,我有两个 DirectedGraph:g1g2

如何将 g1g2 合并到第三个图 g3? 我需要 g3 是一个普通图,并且能够添加新的边和顶点。

最佳答案

终于找到了!

Graphs 类中有一个方法可以将第二个入口图添加到第一个入口图:

Graphs.addGraph(g1, g2);

Adds all the vertices and all the edges of the specified source graph to the specified destination graph. First all vertices of the source graph are added to the destination graph. Then every edge of the source graph is added to the destination graph. This method returns true if the destination graph has been modified as a result of this operation, otherwise it returns false.

我们可以阅读更多here .

关于java - 在 JGraphT 中合并图形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13232450/

相关文章:

java - 在 JGraphT SimpleGraph 中使用相等的顶点

java - 替换 HashSet Java 成员

java - 在java中为各种语言环境格式化给定的货币? (四舍五入问题)

java - 如何在 Axis2 WebService 中通过用户名和密码进行身份验证?

java - GridBagLayout 故障排除

java - 让加权图在 JGraphT 中工作

c# - 使用 .Net 从 Oracle DB 读取数据比使用 Java 快 10 倍

java - 使用 JGraphXAdapter 改变边的颜色

java - 如何在图中表示双向边

java - 字符串时间到实际时间