valos_halozat_hf/app.py

19 lines
483 B
Python
Raw Normal View History

2020-10-02 00:18:14 +02:00
#!/usr/bin/env python3
import igraph as ig
def read_graph(graph_file: str = 'valos_halozat_formatted.txt') -> ig.Graph:
with open(graph_file) as f:
vertices = int(f.readline())
edges = int(f.readline())
result_graph: ig.Graph = ig.Graph(vertices)
for _ in range(edges):
line = f.readline().split('')
result_graph.add_edge(int(line[0]), int(line[1]))
return result_graph
if __name__ == "__main__":
read_graph()