diff options
-rw-r--r-- | networkx/algorithms/bipartite/centrality.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/networkx/algorithms/bipartite/centrality.py b/networkx/algorithms/bipartite/centrality.py index 3eab8342..52437c64 100644 --- a/networkx/algorithms/bipartite/centrality.py +++ b/networkx/algorithms/bipartite/centrality.py @@ -22,6 +22,13 @@ def degree_centrality(G, nodes): centrality : dictionary Dictionary keyed by node with bipartite degree centrality as the value. + Examples + -------- + >>> G = nx.wheel_graph(5) + >>> top_nodes = {0, 1, 2} + >>> nx.bipartite.degree_centrality(G, nodes=top_nodes) + {0: 2.0, 1: 1.5, 2: 1.5, 3: 1.0, 4: 1.0} + See Also -------- betweenness_centrality @@ -120,6 +127,13 @@ def betweenness_centrality(G, nodes): Dictionary keyed by node with bipartite betweenness centrality as the value. + Examples + -------- + >>> G = nx.cycle_graph(4) + >>> top_nodes = {1, 2} + >>> nx.bipartite.betweenness_centrality(G, nodes=top_nodes) + {0: 0.25, 1: 0.25, 2: 0.25, 3: 0.25} + See Also -------- degree_centrality @@ -190,6 +204,13 @@ def closeness_centrality(G, nodes, normalized=True): Dictionary keyed by node with bipartite closeness centrality as the value. + Examples + -------- + >>> G = nx.wheel_graph(5) + >>> top_nodes = {0, 1, 2} + >>> nx.bipartite.closeness_centrality(G, nodes=top_nodes) + {0: 1.5, 1: 1.2, 2: 1.2, 3: 1.0, 4: 1.0} + See Also -------- betweenness_centrality |