import networkx as nx G = nx.read_graphml("campus_map.graphml") def get_weight(u, v, data): congestion_factor = data.get("predicted_congestion", 1) return data['distance'] * congestion_factor path = nx.dijkstra_path(G, source='A', target='B', weight=get_weight)