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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| from py2neo.database import Graph from nlm import NLMLayer, GraphNode, GraphRelation
mem = NLMLayer(graph=Graph(port=7688), fuzzy_node=False, add_inexistence=False, update_props=False)
node = GraphNode("Person", "AliceThree") mem(node)
new = GraphNode("Person", "Bob") mem(new, add_inexistence=True)
node = GraphNode("Person", "AliceT") mem(node, fuzzy_node=True)
node = GraphNode("Person", "AliceThree", props={"age": 24}) mem(node, update_props=True)
node = GraphNode("Person", "AliceT") mem(node, fuzzy_node=True, topn=2)
start = GraphNode("Person", "AliceThree") end = GraphNode("Person", "AliceOne") relation = GraphRelation(start, end, "LOVES") mem(relation)
start = GraphNode("Person", "AliceThree") end = GraphNode("Person", "Bob") relation = GraphRelation(start, end, "KNOWS") mem(relation, add_inexistence=True)
start = GraphNode("Person", "AliceTh") end = GraphNode("Person", "AliceO") relation = GraphRelation(start, end, "LOVES") mem(relation, fuzzy_node=True)
start = GraphNode("Person", "AliceThree") end = GraphNode("Person", "AliceOne") relation = GraphRelation(start, end) mem(relation, topn=3)
start = GraphNode("Person", "AliceThree") end = GraphNode("Person", "Bob") relation = GraphRelation(start, end, "KNOWS", {"roles": "classmate"}) mem(relation, update_props=True)
start = GraphNode("Person", "AliceThree") end = GraphNode("Person", "Bob", {"sex": "male"}) relation = GraphRelation(start, end, "KNOWS", {"roles": "friend"}) mem(relation, update_props=True)
start = GraphNode("Person", "AliceThree") end = GraphNode("Person", "Bob") mem(GraphRelation(start, end), topn=2)
mem.labels
mem.relationship_types
mem.nodes_num
mem.relationships_num
mem.nodes
mem.relationships
mem.query("MATCH (a:Person) RETURN a.age, a.name LIMIT 5") [{'a.age': 21, 'a.name': 'AliceTwo'}, {'a.age': 23, 'a.name': 'AliceFour'}, {'a.age': 22, 'a.name': 'AliceOne'}, {'a.age': 24, 'a.name': 'AliceFive'}, {'a.age': None, 'a.name': 'Bob'} ]
mem.excute("MATCH (a:Person) RETURN a.age, a.name LIMIT 5")
|