add calcs
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
Torma Kristóf 2020-10-02 00:39:25 +02:00
parent 36887410af
commit 4ed4a713b9
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
2 changed files with 11 additions and 3 deletions

View File

@ -3,7 +3,7 @@ type: docker
name: default
steps:
- name: run_tournament
- name: run_homework
image: "python:3.8"
commands:
- pip3 install -r requirements.txt

12
app.py
View File

@ -3,15 +3,23 @@
import igraph as ig
def read_graph(graph_file: str = 'valos_halozat_formatted.txt') -> ig.Graph:
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 result_graph
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__":