I have the following example code:
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
def view_graph(graph, labels):
'''
Plots the graph
'''
pos = nx.spring_layout(graph)
nx.draw(graph, pos, with_labels=True)
nx.draw_networkx_edge_labels(graph, pos,edge_labels=labels)
plt.axis('off')
plt.show()
index_to_name = {1: "Paul", 2: "Magda", 3: "Paul", 4: "Anna", 5: "Marie", 6: "John", 7: "Mark"}
relation = {}
g = nx.DiGraph()
g.add_edge(1, 4)
relation[(1,4)] = "dad"
g.add_edge(2, 4)
relation[(2,4)] = "mom"
g.add_edge(1, 5)
relation[(1,5)] = "dad"
g.add_edge(2, 5)
relation[(2,5)] = "mom"
g.add_edge(3, 6)
relation[(1,6)] = "dad"
g.add_edge(4, 6)
relation[(2,6)] = "mom"
g.add_edge(3, 7)
relation[(1,7)] = "dad"
g.add_edge(4, 7)
relation[(2,7)] = "mom"
view_graph(g, relation)
My illustration window e.g. looks like that:

I have two problems and don't really know how to solve that:
- Is their a possibility to show the names from the dictionary
index_to_namein the illustration instead of the indexes I introduce to ensure unique nodes (in the dictionary the name Paul occurs two times and so the name "Paul" should have two nodes). - How can I fix the problem with the edge labels marked in the illustration with red rectangles. My aim is to add these labels so its clear which edge is being referenced?
I hope you can help me with this two problems.

relation. For example,g.add_edge(3, 6)is followed byrelation[(1,6)] = "dad"when the presumably intended key should berelation[(3,6)] = "dad".