【发布时间】:2012-10-15 06:03:26
【问题描述】:
我需要输出表示为邻接矩阵的给定图的周长。谁能给我一些提示,我可以如何使用邻接矩阵或邻接列表来获得图的周长?
例子:
graph one:
0 1 0 0
1 0 0 1
0 0 0 0
0 1 0 0
graph two:
0 1 0 0 1
1 0 1 0 0
0 1 0 1 0
0 0 1 0 1
1 0 0 1 0
The result:
Girth of graph 1: infinity
Girth of graph 2: 5
【问题讨论】:
-
"图的周长是图中包含的最短环的长度"1
-
我知道这一点。问题是如何使用矩阵或列表获得最短的循环。