import networkx as nx
import matplotlib.pyplot as plt
user_input = list(map(int, input("Enter the edges you want to plot: ").split()))
print("The edges are: ", user_input)
G = nx.Graph()
for x in user_input:
if (x<len(user_input)):
G.add_edge(x, x+1)
ego = user_input[0]
pos = nx.spring_layout(G)
nx.draw(G, pos, node_color="lavender",
arrows=True, arrowstyle='-|>',
node_size=800, with_labels=True)
options = {"node_size": 1200, "node_color": "r"}
nx.draw_networkx_nodes(G, pos, nodelist=[ego], **options)
plt.show()
I want to create like the picture but I can not do it. And also, the numbers of edges is given by the user. This is what I want
and I am getting like this. This is what I am getting
I am hoping the user can give multiple edges and they will be projected like the image.