Created
September 29, 2021 08:09
-
-
Save MJacobs1985/f404e339afbe4d0f29ee36888166b928 to your computer and use it in GitHub Desktop.
Network Graphs for Epidemiology
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
G = nx.Graph() | |
G.add_edge(1, 7) | |
e = (2, 3) | |
G.add_edge(*e) | |
nx.draw(G, with_labels=True, font_weight='bold', font_color='white', node_color='black', node_size=500, alpha=0.8, edge_color='orange') | |
G.add_edges_from([(1, 2), (1, 3)]) | |
nx.draw(G, with_labels=True, font_weight='bold', font_color='white', node_color='black', node_size=500, alpha=0.8, edge_color='orange') | |
H = nx.path_graph(10) | |
G.add_edges_from(H.edges) | |
nx.draw(G, with_labels=True, font_weight='bold', font_color='white', node_color='black', node_size=500, alpha=0.8, edge_color='orange') | |
G = nx.Graph() | |
G.add_edge(1, 2) | |
H = nx.DiGraph(G) # create a DiGraph using the connections from G | |
list(H.edges()) | |
[(1, 2), (2, 1)] | |
edgelist = [(0, 1), (1, 2), (2, 3)] | |
H = nx.Graph(edgelist) | |
nx.draw(H, with_labels=True, font_weight='bold', font_color='white', node_color='black', node_size=500, alpha=0.8, edge_color='orange') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment