本文介绍了NetworkX中的AttributeError,模块没有max_clique属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个属性错误.这是我的代码:
like said in the title I have an attribute error.Here is my code:
from sympy import *
import numpy as np
import networkx as nx
G=nx.Graph()
with open ("testing.txt", "r") as myfile:
Matrice=eval(myfile.readline())
Matnum = np.array(np.array(Matrice))
Matnum = Matnum.astype(np.int, copy=False)
G.add_node(Matnum.shape[1])
for i in range(0,Matnum.shape[1]):
for j in range(i+1,Matnum.shape[1]):
if Matnum[i,j] == 1:
G.add_edge(i,j)
print nx.max_clique(G)
有关信息,阅读行是由另一个脚本创建的矩阵:
for information the reading line is a Matrix created by another script:
Matrix([[1, 1, 1, 0, 0, ....... 0, 0, 1, 0, 1]])
您有解决方案吗?谢谢
Have you a solution?Thks
推荐答案
文档对此位置有点含糊不清,但以下内容对我有用:
The docs are a bit ambiguous about where this resides but the following worked for me:
In [4]:
G = nx.complete_graph(4)
from networkx.algorithms.approximation import clique
clique.max_clique(G)
Out[4]:
{0, 1, 2, 3}
这篇关于NetworkX中的AttributeError,模块没有max_clique属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!