import networkx as nx import matplotlib.pyplot as plt
g = nx.Graph()
g.add_node(1)
g.add_nodes_from([2,3,4,5])
g.nodes()
g.add_edges_from([(1,2),(1,3),(4,1),(4,5)])
g.edges()
nx.draw(g,with_labels=True)