gpt4 book ai didi

java - 添加两条边 - JGraphT

转载 作者:行者123 更新时间:2023-12-02 01:49:42 26 4
gpt4 key购买 nike

我正在使用SimpleDirectedWeightedGraph来自JGrapghT 1.2.0图书馆。我的目标是在顶点 A 之间创建两条边和B这样A <-80-> B 。如果我这样做:

graph.addEdge("A", "B", 80);
graph.addEdge("B", "A", 80);
System.out.println(graph.getAllEdges("A", "B"));
System.out.println(graph.getAllEdges("B", "A"));

我得到:

[80]
[]

如果我将第二行更改为: graph.addEdge("B", "A", 81); ,我明白

[80]
[81]

为什么我不能在具有相同值的顶点之间创建两条边?

最佳答案

来自JavaDocsSimpleDirectedGraph上:

A simple directed graph. A simple directed graph is a directed graph in which neither multiple (parallel) edges between any two vertices nor loops are permitted.

关于java - 添加两条边 - JGraphT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53167391/

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