networkx draw labels code example
Example 1: networkx draw labels
>>> G.add_edge(1, 2)
>>> e = (2, 3)
>>> G.add_edge(*e) # unpack edge tuple*
Example 2: networkx draw labels
>>> G.add_edges_from([(1, 2), (1, 3)])
Example 3: networkx draw labels
>>> G.number_of_nodes()
8
>>> G.number_of_edges()
3
Example 4: nx draw with labels
import networkx as nx
import matplotlib.pyplot as plt
G=nx.Graph()
# Add nodes and edges
G.add_edge("Node1", "Node2")
nx.draw(G, with_labels=True)