Torma Kristóf
4ed4a713b9
Some checks reported errors
continuous-integration/drone/push Build was killed
27 lines
830 B
Python
27 lines
830 B
Python
#!/usr/bin/env python3
|
|
|
|
import igraph as ig
|
|
|
|
|
|
def read_graph(graph_file: str = 'valos_halozat_formatted.txt') -> map:
|
|
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(' ')
|
|
print(line)
|
|
result_graph.add_edge(int(line[0]), int(line[1]))
|
|
return {"graph": result_graph, "edges:": edges, "vertices": vertices}
|
|
|
|
|
|
def calclulate_values(data: map):
|
|
print(f"Komponensek: {data['graph'].clusters()}")
|
|
print(f"Atlagos fokszam: {(data['edges']*2)/data['vertices']}")
|
|
print(f"Atmero: {data['graph'].diameter()}")
|
|
print(f"Atlagos ut hossz: {data['graph'].average_path_length()}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
read_graph()
|