@@ -56,28 +56,25 @@ def __init__(self, graph, index):
56
56
Graph to which the partition index refers to.
57
57
58
58
index : dict
59
- A dict that maps module labels to sets of nodes, this describes the
60
- partition in full.
59
+ A dict of sets that maps module/partition labels to sets of
60
+ nodes, this describes the partition in full.
61
61
62
62
Note
63
63
----
64
- The values in the index dict MUST be real sets, not lists. No checks
65
- are made of this fact, but later the code relies on them being sets and
66
- may break in strange manners if the values were stored in non-set
67
- objects.
64
+ The values in the index dict MUST be real sets, not lists.
68
65
"""
69
66
# Store references to the original graph and label dict
70
67
if not type (index ) == type ({}):
71
- raise TypeError ('index should be of type dict(), not %s' % type ( index ))
72
-
68
+ raise TypeError ('index should be of type dict(),' \
69
+ 'not %s' % type ( index ))
73
70
self .index = copy .deepcopy (index )
74
71
75
72
## add quick check to make sure the passed index is
76
73
## a dict of sets
77
74
self ._check_index_contains_sets ()
78
75
79
76
# We'll need the graph's adjacency matrix often, so store it once
80
- self .graph_adj_matrix = nx .adj_matrix (graph )
77
+ self .graph_adj_matrix = np . triu ( nx .adj_matrix (graph ) )
81
78
#make sure adj_matrix is binary otherwise raise exception
82
79
if not self .graph_adj_matrix .sum () == \
83
80
self .graph_adj_matrix .astype (bool ).sum ():
0 commit comments