3
Compute some network properties for the lollipop graph.
5
# Copyright (C) 2004 by
6
# Aric Hagberg <hagberg@lanl.gov>
7
# Dan Schult <dschult@colgate.edu>
8
# Pieter Swart <swart@lanl.gov>
9
# Distributed under the terms of the GNU Lesser General Public License
10
# http://www.gnu.org/copyleft/lesser.html
12
from networkx import *
14
G = lollipop_graph(4,6)
18
print "source vertex {target:length, }"
20
spl=single_source_shortest_path_length(G,v)
22
for p in spl.values():
26
print "average shortest path length ", sum(pathlengths)/len(pathlengths)
28
# histogram of path lengths
43
print "radius: ",radius(G)
44
print "diameter: ",diameter(G)
45
print "eccentricity: ",eccentricity(G,with_labels=True)
46
print "center: ",center(G)
47
print "periphery: ",periphery(G)
48
print "density: ", density(G)