This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
def build_graph(edge_list): | |
graph = defaultdict(list) | |
seen_edges = defaultdict(int) | |
for src, dst, weight in edge_list: | |
seen_edges[(src, dst, weight)] += 1 | |
if seen_edges[(src, dst, weight)] > 1: # checking for duplicated edge entries | |
continue |