-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.py
45 lines (33 loc) · 1.08 KB
/
test.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
40
41
42
43
44
45
from dagoba.graph import Graph
from dagoba.query import Query
from dagoba.entities import Vertex, Edge
import sys
class Person(Vertex):
def __init__(self, name, age):
super().__init__()
self.name = name
self.age = age
class Relationship(Edge):
def __init__(self, name, src: Vertex, target: Vertex):
super().__init__(src, target)
self.name = name
def main(args):
graph = Graph()
rah = Person('Rahul', 21)
tom = Person('Tom', 25)
kat = Person('Kate', 20)
raj = Person('Raj', 25)
graph.addVertex(rah)
graph.addVertex(tom)
graph.addVertex(kat)
graph.addVertex(raj)
graph.addEdge(Relationship('Friends', rah, raj))
graph.addEdge(Relationship('Friends', raj, kat))
graph.addEdge(Relationship('Friends', rah, tom))
graph.addEdge(Relationship('Friends', tom, kat))
graph.addEdge(Relationship('Friends', tom, raj))
graph.addEdge(Relationship('Friends', tom, rah))
print(graph.v({'age': 25}).out().property('name').take(2).run())
if __name__ == '__main__':
args = sys.argv
main(args)