# Data for the problem
NODES = ["a", "b", "c", "d", "e", "f", "g"]
EDGES = [
("a", "b"),
("a", "c"),
("b", "d"),
("b", "e"),
("c", "d"),
("c", "f"),
("d", "e"),
("d", "f"),
("e", "g"),
("f", "g"),
]
weights = [50, 100, 40, 20, 60, 20, 50, 60, 70, 70]
weights_df = pd.DataFrame(
{"weights": weights}, index=pd.MultiIndex.from_tuples(EDGES, names=["from", "to"])
).reset_index()
ppos = {
"a": (0, 1),
"b": (1, 2),
"c": (1, 0),
"d": (2, 1),
"e": (3, 2),
"f": (3, 0),
"g": (4, 1),
}
G = nx.from_pandas_edgelist(
weights_df, "from", "to", edge_attr="weights", create_using=nx.DiGraph()
)
elabels = nx.get_edge_attributes(G, "weights")
# Plot the graph
plot_graph(Graph=G, plot_pos=ppos, edge_labels=elabels)