0

First, thanks for taking the time to read and respond.

Second, the question:
I am trying to form a weighted undirected graph from my symmetric adjacency matrix, A, where the ij-th element is the edge weight between nodes i and j:

import igraph as ig
g = ig.Graph.Weighted_Adjacency(A, attr="weight", loops=False, mode=ADJ_MAX)

I get this a name error right off the bat:

NameError: name 'ADJ_MAX' is not defined

Now, I can convert my directed graph to an undirected one by:

g = ig.Graph.Weighted_Adjacency(A, attr="weight", loops=False)
g.to_undirected()

but I am wondering what the problem is.

4

1 回答 1

1

使用ig.ADJ_MAX而不是ADJ_MAX. 在模块ADJ_MAX的命名空间中定义。igraph

或者,您可以键入from igraph import ADJ_MAX,将ADJ_MAX常量拉入您的本地命名空间,然后您可以在没有限定条件的情况下使用它。

于 2015-10-19T19:19:17.620 回答