January 2018
Beginner to intermediate
262 pages
6h 3m
English
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) ... |
Read now
Unlock full access