This commit is contained in:
parent
36887410af
commit
4ed4a713b9
@ -3,7 +3,7 @@ type: docker
|
|||||||
name: default
|
name: default
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: run_tournament
|
- name: run_homework
|
||||||
image: "python:3.8"
|
image: "python:3.8"
|
||||||
commands:
|
commands:
|
||||||
- pip3 install -r requirements.txt
|
- pip3 install -r requirements.txt
|
||||||
|
12
app.py
12
app.py
@ -3,15 +3,23 @@
|
|||||||
import igraph as ig
|
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:
|
with open(graph_file) as f:
|
||||||
vertices = int(f.readline())
|
vertices = int(f.readline())
|
||||||
edges = int(f.readline())
|
edges = int(f.readline())
|
||||||
result_graph: ig.Graph = ig.Graph(vertices)
|
result_graph: ig.Graph = ig.Graph(vertices)
|
||||||
for _ in range(edges):
|
for _ in range(edges):
|
||||||
line = f.readline().split(' ')
|
line = f.readline().split(' ')
|
||||||
|
print(line)
|
||||||
result_graph.add_edge(int(line[0]), int(line[1]))
|
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__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user