From 4ed4a713b91635a181cb74c7ba9a910c157f1b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Fri, 2 Oct 2020 00:39:25 +0200 Subject: [PATCH] add calcs --- .drone.yml | 2 +- app.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9446d7a..9653c99 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 diff --git a/app.py b/app.py index 9a7ccf7..2d327eb 100644 --- a/app.py +++ b/app.py @@ -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__":