gpt4 book ai didi

java - 如何将带权无向图显示为二维数组(以矩阵形式)?

转载 作者:行者123 更新时间:2023-12-01 23:14:09 26 4
gpt4 key购买 nike

enter image description here

大家好,尝试在这里做一个实验,但我无法理解如何在三乘三矩阵(G,右)中显示图表(左)中的节点。我不是在研究如何在 java 中打印矩阵。

它说:

Here, the edge between each node i and j is represented by a number that indicates the edge weight. In the diagram, the edge between node 1 and 3 can be seen at row 1, column 3 and has value 2.

最佳答案

在这种情况下,节点是矩阵的索引。您必须了解 java 中基于零的索引,因此节点 1 实际上位于 [0,0] 位置等。

the edge between node 1 and 3 can be seen at row 1, column 3 and has value 2 means edge weight is 2 and is in [0,2], and since graph is undirected also in [2,0].

请注意,表示无向图的矩阵是转置的。

关于java - 如何将带权无向图显示为二维数组(以矩阵形式)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21469955/

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