-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (46 loc) · 1.4 KB
/
main.py
File metadata and controls
55 lines (46 loc) · 1.4 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from src.automaton import RegexAutomaton
from src.graph import LabelGraph
import argparse
from src.rpq import perform_rpq
def main():
parser = argparse.ArgumentParser(description='Basic graph DB')
parser.add_argument(
'--graph', required=True, type=str,
help='path to graph file'
)
parser.add_argument(
'--regex', required=True, type=str,
help='path to regex file'
)
parser.add_argument(
'--start', required=False, type=str,
help='path to given starting vertices'
)
parser.add_argument(
'--end', required=False, type=str,
help='path to given end vertices'
)
args = parser.parse_args()
# read Regex from file
regex_string = open(args.regex, 'r').read()
regex_automaton = RegexAutomaton(regex_string)
# read GrB matrix from file
graph = LabelGraph().from_txt(args.graph)
# read start and end vertices
start = []
if (args.start is not None):
with open(args.start, 'r') as f:
for line in f:
start.append(int(line))
else:
start = list(range(graph.num_vert))
end = []
if (args.end is not None):
with open(args.end, 'r') as f:
for line in f:
end.append(int(line))
else:
end = list(range(graph.num_vert))
perform_rpq(graph, regex_automaton, start, end)
if __name__ == "__main__":
main()