iGraph

Here’s how iGraph deals with the Lincoln graph. The edge list contains numerical node identifiers rather than labels, but you can add the labels later as node attributes.

 import​ ​igraph
 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 = igraph.Graph(edges, directed=True)
 G.add_vertex(14)
 G.vs[​"name"​] = labels
 print​(G)
<= IGRAPH DN-- 15 13 --
 + attr: name (v) ...

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.