【发布时间】:2019-08-05 11:47:33
【问题描述】:
我遇到了这个公式来获得无向图中的 4 循环数:
[![formula to calculate the number of 4-cycle][1]][1]
Ck = 1/2k Tr(Pk-1 A)
k stands for k-cycle, and A is the adjacency matrix, Pk-1 is the path count matrix
网页链接:
[数学世界]http://mathworld.wolfram.com/GraphCycle.html
我现在正在尝试在 python 中编写这个简单的公式,我可以使用 NetworkX 的 adjacency_matrix 函数来获取邻接矩阵,并且我也可以得到矩阵迹线。我只是不确定所谓的路径计数 Pk 矩阵,我用谷歌搜索了一段时间,但没有找到对此的直接解释。专家能否建议这个 Pk 矩阵是什么,我想知道是否可以用 Python 对其进行编码?
提前致谢!
【问题讨论】:
标签: python graph networkx cycle discrete-mathematics