Torma Kristóf
10c8976554
All checks were successful
continuous-integration/drone/push Build is passing
28 lines
943 B
Python
28 lines
943 B
Python
#!/usr/bin/env python3
|
|
|
|
import igraph as ig
|
|
|
|
|
|
def read_graph(graph_file: str = 'kis_dataset.txt') -> dict:
|
|
with open(graph_file) as f:
|
|
vertices = int(f.readline())
|
|
edges = int(f.readline())
|
|
result_graph: ig.Graph = ig.Graph(vertices)
|
|
for _ in range(1, edges):
|
|
line = f.readline().split('\t')
|
|
result_graph.add_edge(int(line[0]), int(line[1]))
|
|
return {"graph": result_graph, "edges": edges, "vertices": vertices}
|
|
|
|
|
|
def calclulate_values(graph_data: dict):
|
|
print(f"Atmero: {graph_data['graph'].diameter()}")
|
|
print(f"Klaszterek: {graph_data['graph'].clusters()}")
|
|
print(f"Klaszterek szama: {len(graph_data['graph'].clusters())}")
|
|
print(f"Atlagos ut hossz: {graph_data['graph'].average_path_length()}")
|
|
print(f"Atlagos fokszam: {(graph_data['edges'] * 2) / graph_data['vertices']}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
data = read_graph()
|
|
calclulate_values(data)
|