Statistics
| Branch: | Revision:

iof-tools / networkxMiCe / networkx-master / examples / algorithms / plot_krackhardt_centrality.py @ 5cef0f13

History | View | Annotate | Download (899 Bytes)

1
#!/usr/bin/env python
2
"""
3
=====================
4
Krackhardt Centrality
5
=====================
6

7
Centrality measures of Krackhardt social network.
8
"""
9
# Author: Aric Hagberg (hagberg@lanl.gov)
10
# Date: 2005-05-12 14:33:11 -0600 (Thu, 12 May 2005)
11
# Revision: 998
12

    
13
#    Copyright (C) 2004-2019 by
14
#    Aric Hagberg <hagberg@lanl.gov>
15
#    Dan Schult <dschult@colgate.edu>
16
#    Pieter Swart <swart@lanl.gov>
17
#    All rights reserved.
18
#    BSD license.
19

    
20
import matplotlib.pyplot as plt
21
import networkx as nx
22

    
23
G = nx.krackhardt_kite_graph()
24

    
25
print("Betweenness")
26
b = nx.betweenness_centrality(G)
27
for v in G.nodes():
28
    print("%0.2d %5.3f" % (v, b[v]))
29

    
30
print("Degree centrality")
31
d = nx.degree_centrality(G)
32
for v in G.nodes():
33
    print("%0.2d %5.3f" % (v, d[v]))
34

    
35
print("Closeness centrality")
36
c = nx.closeness_centrality(G)
37
for v in G.nodes():
38
    print("%0.2d %5.3f" % (v, c[v]))
39

    
40
nx.draw(G)
41
plt.show()