嘿,我需要輸出一個給定圖的周長表示爲一個鄰接矩陣。任何人都可以給我一些提示,我可以如何使用鄰接矩陣或鄰接列表來獲得一個周長圖表?由於找到一個圖的周長
例子:
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](http://en.wikipedia.org/wiki/Girth_(graph_theory)) –
我知道這一點。問題是如何使用矩陣或列表來獲得最短週期。 – Rennos