Пример #1
0
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)

label0 = storageManager.createLabel("numb")
label1 = storageManager.createLabel("numb")
Пример #2
0
crookshanks.addProperty(propBlue)
crookshanks.addLabel(catLabel)

hermione2 = storageManager.createNode()
propHermioneName2 = storageManager.createProperty("Name", "Hermione Granger_clone")
hermione2.addProperty(propHermioneName2)
hermione2.addLabel(hermioneLabel)

crookshanks2 = storageManager.createNode()
propCrookshanksName2 = storageManager.createProperty("Name", "Crookshanks_clone")
crookshanks2.addProperty(propCrookshanksName2)
crookshanks2.addProperty(propBlue)
crookshanks2.addLabel(catLabel)

# create relationships
rel0 = storageManager.createRelationship(hermione, crookshanks, "ownership")
hermione.addRelationship(rel0)
crookshanks.addRelationship(rel0)

rel1 = storageManager.createRelationship(harryPotter, ron, "friendship")
harryPotter.addRelationship(rel1)
ron.addRelationship(rel1)

rel2 = storageManager.createRelationship(harryPotter, hermione, "friendship")
harryPotter.addRelationship(rel2)
hermione.addRelationship(rel2)

rel3 = storageManager.createRelationship(hermione, ron, "friendship")
hermione.addRelationship(rel3)
ron.addRelationship(rel3)