import networkx as nx
ranked_node_names = [['start'], [1, 2, 3], ['a', 'b', 'c'], ['end']]
node_edges = [('start', 2), ('start', 3), (2, 'b'), ('b', 'end'), ('a', 'end')]
G = nx.DiGraph()
for rank_of_nodes in ranked_node_names:
    G.add_nodes_from(rank_of_nodes)
G.nodes(data=True)
G.add_edges_from(node_edges)
A = nx.to_agraph(G)
A.graph_attr.update(rankdir='LR')
for rank_of_nodes in ranked_node_names:
    A.add_subgraph(rank_of_nodes, rank='same')
A.draw('example.png', prog='dot')
python drawing directed graph in SPYDER