import networkx as nx import matplotlib.pyplot as plt G=nx.Graph() G.add_edges_from([('A','B'),('A','C'),('B','D'),('C','D')]) nx.draw(G) plt.show()
G.remove_node('B') nx.draw(G) plt.show()
To remove multiple nodes, there is also a Graph.remove_nodes_from () method.
source share