O'Reilly logo

Complex Network Analysis in Python by Dmitry Zinoviev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

graph-tool

The graph-tool version of the Lincoln graph starts with the same edge list and a list of labels. All vertices are added at once, followed by all edges. graph-tool treats labels as vertex properties.

 import​ ​graph_tool
 edges = [(1, 6), (1, 7), (1, 5), (1, 12), (2, 4), (2, 9), (3, 13), (7, 0),
  (7, 2), (7, 3), (8, 1), (8, 10), (8, 11)]
 labels = [
 "A.L. II"​, ​"A.L."​, ​"Thomas L."​, ​"Jessie Harlan L."​, ​"Mary L. Beckwith"​,
 "Sarah L. Grigsby"​, ​"Edward Baker L."​, ​"Mary L."​, ​"William Wallace L."​,
 "Robert Todd L."​, ​"Robert Todd L. Beckwith"​, ​"Thomas L. Jr."​,
 "Thomas L. III"​, ​"L. Isham"​, ​"George W."​]
 
 G = graph_tool.Graph() ​# Directed by default
 nodes = G.add_vertex(len(labels))
 G.add_edge_list(edges) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required