17 lines
556 B
Python
17 lines
556 B
Python
|
import sys
|
||
|
|
||
|
with open(sys.argv[1]) as f:
|
||
|
num_nodes, num_edges = map(int, f.readline().strip().split(" "))
|
||
|
all_edges = set()
|
||
|
for _ in range(num_edges):
|
||
|
from_edge, to_edge = map(int, f.readline().strip().split(" "))
|
||
|
all_edges.add((from_edge, to_edge))
|
||
|
all_edges.add((to_edge, from_edge))
|
||
|
|
||
|
all_edges = sorted(list(all_edges))
|
||
|
new_num_edges = len(all_edges)
|
||
|
|
||
|
with open(sys.argv[2], "w") as f:
|
||
|
f.write(f"{num_nodes} {new_num_edges}\n")
|
||
|
for from_edge, to_edge in all_edges:
|
||
|
f.write(f"{from_edge} {to_edge}\n")
|