NetworkX中的AttributeError,模块没有max_clique attribu

2024-09-28 16:59:41 发布

您现在位置:Python中文网/ 问答频道 /正文

就像标题里说的我有个属性错误。 这是我的代码:

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)   

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

^{pr2}$

Download it for testing!

你有解决办法吗? 厚度


Tags: inimportadd标题forasnprange
2条回答

您应该增加堆空间

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size

java -Xms1024m -Xmx2048m

好书From Java code to Java heap

Table 3. Attributes of a HashMap
Default capacity                     16 entries
Empty size                           128 bytes
Overhead                             64 bytes plus 36 bytes per entry
Overhead for a 10K collection   ~    360K
Search/insert/delete performance    O(1) — Time taken is constant time, regardless of the number of elements (assuming no hash collisions)

如果您考虑上面的表开销为^ {CD1>}记录到大约^ {< CD2>},那么您的最小堆大小必须在^ {< CD3>}/P>

以及改变堆大小,考虑将“压缩”(编码)键存储为填充二进制,而不是String。

每个IP地址可以存储为4个字节。端口号(如果是这样的话)每个是2个字节。协议可能存储为一个字节或更少

这是13个字节,而不是作为UTF16字符串存储的70个字节,如果我的数学在晚上这个时候是正确的,那么键的内存将减少5倍

相关问题 更多 >