Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
448 B
1
Indexable
Never
edge_colors = ['green' if graph.edges[e]['color'] == 'green' else 'purple' for e in graph.edges]
node_colors = ['red' if graph.nodes[n]['color'] == 'red' else 'blue' for n in graph.nodes]

# Draw the graph
pos = nx.spring_layout(graph)
nx.draw_networkx_nodes(graph, pos, node_size=300, node_color=node_colors)
nx.draw_networkx_edges(graph, pos, edge_color=edge_colors)
nx.draw_networkx_labels(graph, pos, font_size=10)
plt.axis('off')
plt.show()