You can get the weight of each edge in a networkx graph in python as follows:
main.py287 chars16 lines
Output:
main.py46 chars2 lines
Explanation:
G.('A', 'B'), ('B', 'C'), and ('A', 'C') with weights 3, 4, and 2, respectively.get_edge_attributes() function to get the weight of each edge. This function returns a dictionary with edge tuples as keys and their corresponding weight as values.gistlibby LogSnag