gpt4 book ai didi

java - 在 JGraphT 中合并图形

转载 作者:搜寻专家 更新时间:2023-11-01 01:45:09 24 4
gpt4 key购买 nike

我正在使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com