-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
41 lines (31 loc) · 1.24 KB
/
__main__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
import os
from graph import Graph
DATA_DIR = "data/"
PLOTS_DIR = DATA_DIR + "plots/"
TABLES_DIR = DATA_DIR + "tables/"
RESOURCES_DIR = "resources/"
DEFAULT_VERTICE_COUNT = 1000
def generate_edgar_gilbert_graph(vertice_count):
graph = Graph.edgar_gilbert_graph(vertice_count)
graph.write_edges(RESOURCES_DIR + "edgar_gilbert_graph.csv")
def generate_barabasi_albert_graph(vertice_count):
graph = Graph.barabasi_albert_graph(vertice_count)
graph.write_edges(RESOURCES_DIR + "barabasi_albert_graph.csv")
def generate_plot(filepath: str):
graph = Graph.read_edges(filepath)
filename = os.path.splitext(os.path.basename(filepath))[0] + '.png'
graph.write_plot(PLOTS_DIR + filename)
graph.generate_table_parameters(TABLES_DIR + filename)
if __name__ == "__main__":
if len(sys.argv) >= 2:
vertice_count = DEFAULT_VERTICE_COUNT
if sys.argv[1] == "graph":
if len(sys.argv) > 3:
vertice_count = int(sys.argv[3])
if sys.argv[2] == "eg":
generate_edgar_gilbert_graph(vertice_count)
elif sys.argv[2] == "ba":
generate_barabasi_albert_graph(vertice_count)
elif sys.argv[1] == "plot":
generate_plot(sys.argv[2])