Optimization, Operations Research, Python, Data Science, Editors Pick.
file with open($YOUR_FILE_PATH, mode="r") as file: lines = file.readlines() header = lines[0].strip().split() n_nodes = int(header[2]) edges = [] node_set = set() for line in lines[1:]: if line.startswith('e'): _, i, j = line.strip().split() edges.append((int(i), int(j))) node_set.add(int(i))