initial commit

This commit is contained in:
2026-03-02 20:55:36 +09:00
commit f224644b49
86 changed files with 1065250 additions and 0 deletions
@@ -0,0 +1,21 @@
def dimacs_convert_graph(filename):
with open(filename, 'r') as f:
for line in f:
line = line.strip()
if line.startswith('c'):
continue
elif line.startswith('p'):
_, _, n, e = line.split()
nodes = int(n)
edges = int(e)
adj = [[] for _ in range(nodes + 1)]
elif line.startswith('a'):
_, u, v, w = line.split()
u, v, w = int(u) - 1, int(v) - 1, int(w)
adj[u].append((v, w))
return nodes, adj