Say I have a graph with 10
nodes, and I want to plot it when:
- It is intact
- It has had a couple of nodes removed
How can I make sure that the second plot has exactly the same positions as the first one?
My attempt generates two graphs that are drawn with a different layout:
import networkx as nx
import matplotlib.pyplot as plt
%pylab inline
#Intact
G=nx.barabasi_albert_graph(10,3)
fig1=nx.draw_networkx(G)
#Two nodes are removed
e=[4,6]
G.remove_nodes_from(e)
plt.figure()
fig2=nx.draw_networkx(G)