diff options
Diffstat (limited to 'networkx/linalg/modularitymatrix.py')
-rw-r--r-- | networkx/linalg/modularitymatrix.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/networkx/linalg/modularitymatrix.py b/networkx/linalg/modularitymatrix.py index 927bff93..e2b8f905 100644 --- a/networkx/linalg/modularitymatrix.py +++ b/networkx/linalg/modularitymatrix.py @@ -2,11 +2,12 @@ """ import networkx as nx from networkx.utils import not_implemented_for -__all__ = ['modularity_matrix', 'directed_modularity_matrix'] +__all__ = ["modularity_matrix", "directed_modularity_matrix"] -@not_implemented_for('directed') -@not_implemented_for('multigraph') + +@not_implemented_for("directed") +@not_implemented_for("multigraph") def modularity_matrix(G, nodelist=None, weight=None): r"""Returns the modularity matrix of G. @@ -63,8 +64,7 @@ def modularity_matrix(G, nodelist=None, weight=None): """ if nodelist is None: nodelist = list(G) - A = nx.to_scipy_sparse_matrix(G, nodelist=nodelist, weight=weight, - format='csr') + A = nx.to_scipy_sparse_matrix(G, nodelist=nodelist, weight=weight, format="csr") k = A.sum(axis=1) m = k.sum() * 0.5 # Expected adjacency matrix @@ -72,8 +72,8 @@ def modularity_matrix(G, nodelist=None, weight=None): return A - X -@not_implemented_for('undirected') -@not_implemented_for('multigraph') +@not_implemented_for("undirected") +@not_implemented_for("multigraph") def directed_modularity_matrix(G, nodelist=None, weight=None): """Returns the directed modularity matrix of G. @@ -139,8 +139,7 @@ def directed_modularity_matrix(G, nodelist=None, weight=None): """ if nodelist is None: nodelist = list(G) - A = nx.to_scipy_sparse_matrix(G, nodelist=nodelist, weight=weight, - format='csr') + A = nx.to_scipy_sparse_matrix(G, nodelist=nodelist, weight=weight, format="csr") k_in = A.sum(axis=0) k_out = A.sum(axis=1) m = k_in.sum() |