This is my extended work from here.
I would like to set the last element 'm'
in the unique_liss
appears at the top position of the rest nodes like this.
However, most of the image generated would be like this:
this is my codes:
Unique_liss= ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm']
edgesList= [('a', 'b'), ('b', 'c '), ('c ', 'd'), ('d', 'e'), ('d', 'f'), ('e', 'g'), ('f', 'g'), ('g', 'h'), ('h', 'i '), ('i ', 'j'), ('j', 'k'), ('j', 'l'), ('k', 'm'), ('l', 'm')]
import networkx as nx
import matplotlib.pyplot as plt
G = nx.DiGraph()
for node in edgesList:
print('node-', node)
G.add_edge(*node,sep=',')
A = nx.adjacency_matrix(G).A
import numpy as np
seed = 31
pos = nx.spring_layout(G)
plt.figure(figsize=(15,8))
nx.draw(G, pos=pos, with_labels=True, node_size = 1500,
seed=seed, node_color = 'skyblue')
Although i change the for ..loop into a reversed loop as below:
for node in reversed(edgesList):
print('node-', node)
G.add_edge(*node,sep=',')
it's doesn't guarantees that the last element of the node 'm'
to be appread on the top position of the rest.
Appreciate if anyone can help on how to set the last node to be permanently appear at the top position ?