January 2018
Beginner to intermediate
262 pages
6h 3m
English
You do not have to mess with matrices, NumPy, and Pandas to bulk move data between your code and NetworkX networks. You can use edge lists and node dictionaries.
An edge list is a list of 3-tuples containing the start node, end node, and a dictionary of edge attributes for each edge. You can obtain it from an existing network by calling nx.to_edgelist or construct it yourself and feed as the parameter to nx.from_edgelist to produce a new network.
| | edges = nx.to_edgelist(G) |
| | F = nx.from_edgelist(edges) |
| | print(F.edges(data=True)) |
| <= | [('Born', 'Married', {'weight': 1}), ('Married', 'Elected Rep', |
| | {'weight': 1}), ('Elected Pres', 'Died', {'weight': 1}), |
| | ('Died', 'Born', {'weight': 0.1}), ... |
Read now
Unlock full access