If edges.csv lists both Nairobi→Nakuru and Nakuru→Nairobi, Graph.add_edge still stores one undirected edge.
Goal
Count unique roads after loading both directions.
import networkx as nx
G = nx.Graph()
G.add_edge('Nairobi', 'Nakuru', weight=160)
G.add_edge('Nakuru', 'Nairobi', weight=160)
print(G.number_of_edges())
print(G['Nairobi']['Nakuru'])import networkx as nx
D = nx.DiGraph()
D.add_edge('Nairobi', 'Nakuru')
D.add_edge('Nakuru', 'Nairobi')
print(D.number_of_edges())import networkx as nx
print(nx.Graph([('a', 'b'), ('b', 'a')]).number_of_edges())import networkx as nx
G = nx.Graph()
G.add_weighted_edges_from([('Nairobi', 'Nakuru', 160), ('Nakuru', 'Kisumu', 180)])
print(G.size(weight='weight'))