I've created a graph as shown below. However, I'd like to arrange the graph hierarchically by shortest distance from the head (A). In other words: C, B, D, E should all be in the same level and horizontally aligned, since they're each all 1 edge (shortest path) away from A. Then, F, G, H should be in the next level since they're each 2 edges away, etc.
I like the way the graph looks, so the solution would ideally keep this visualization style.
import matplotlib.pyplot as plt
import networkx as nx
import pydot
from networkx.drawing.nx_pydot import graphviz_layout
from IPython.display import Image, display
G=nx.Graph()
G.add_edges_from([
('A','B'),
('A','C'),
('A','E'),
('A','D'),
('B','C'),
('B','F'),
('C','F'),
('D','H'),
('D','G'),
('E','H'),
('F','I'),
('G','I'),
('G','J'),
('H','J'),
('I','K'),
('J','K')
])
pdot = nx.drawing.nx_pydot.to_pydot(G)
graph = Image(pdot.create_png())
display(graph)