NetworkX中的AttributeError,模块没有max_clique属性

Ale*_*Jud -1 python networkx

喜欢在标题中说我有一个属性错误.这是我的代码:

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)   
Run Code Online (Sandbox Code Playgroud)

作为信息,阅读线是由另一个脚本创建的矩阵:

Matrix([[1, 1, 1, 0, 0, ....... 0, 0, 1, 0, 1]])
Run Code Online (Sandbox Code Playgroud)

下载它进行测试!

你有解决方案吗?THKS

EdC*_*ica 8

这些文档对于它所在的位置有点模糊,但以下内容对我有用:

In [4]:

G = nx.complete_graph(4)
from networkx.algorithms.approximation import clique
clique.max_clique(G)
Out[4]:
{0, 1, 2, 3}
Run Code Online (Sandbox Code Playgroud)