示例#1
0
from storage.Relationship import Relationship
from storage.RelationshipFile import RelationshipFile
from storage.Label import Label
from storage.LabelFile import LabelFile
from storage.StorageManager import StorageManager

nodeFile = NodeFile()
relationshipFile = RelationshipFile()
propFile = PropertyFile()
labelFile = LabelFile()

storageManager = StorageManager(nodeFile, relationshipFile, propFile,
                                labelFile)

# create two nodes
node0 = storageManager.createNode()
node1 = storageManager.createNode()

rel0 = storageManager.createRelationship(node0, node1, "friendship")
node0.addRelationship(rel0)
node1.addRelationship(rel0)

prop0 = storageManager.createProperty("1", "2")
prop1 = storageManager.createProperty("3", "4")
prop2 = storageManager.createProperty("5", "1")
prop3 = storageManager.createProperty("years", "9")
prop4 = storageManager.createProperty("years", 9)
prop5 = storageManager.createProperty(">18 years", False)
prop6 = storageManager.createProperty("exact years", 9.5)

rel0.addProperty(prop3)
示例#2
0
from storage.LabelFile import LabelFile
from storage.StorageManager import StorageManager

from parse.SimpleTypes import DummyNode, DummyRelationship

from queryeval.degreeQueries import breadthFirstSearch

# initial set up
nodeFile = NodeFile()
relationshipFile = RelationshipFile()
propFile = PropertyFile()
labelFile = LabelFile()
storageManager = StorageManager(nodeFile, relationshipFile, propFile, labelFile)

# create nodes
harryPotter = storageManager.createNode()
propPotterName = storageManager.createProperty("Name", "Harry Potter")
hpLabel1 = storageManager.createLabel("Harry Potter")
hpLabel2 = storageManager.createLabel("Half Blood")
harryPotter.addProperty(propPotterName)
harryPotter.addLabel(hpLabel1)
harryPotter.addLabel(hpLabel2)

ron = storageManager.createNode()
propRonName = storageManager.createProperty("Name", "Ronald Weasley")
ronLabel = storageManager.createLabel("Pure Blood")
ron.addProperty(propRonName)
ron.addLabel(ronLabel)

hermione = storageManager.createNode()
propHermioneName = storageManager.createProperty("Name", "Hermione Granger")