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) ...

Get Complex Network Analysis in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.