Created
May 8, 2012 21:59
-
-
Save szarnyasg/2639711 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GraphDatabaseService graphDb = new EmbeddedGraphDatabase("tempdb"); | |
Transaction tx = graphDb.beginTx(); | |
try { | |
// graph: (0)---"A"--->(1)---"B"--->(2) (3) | |
List<Node> nodes = new ArrayList<Node>(); | |
for (int i = 0; i < 4; i++) { | |
Node node = graphDb.createNode(); | |
node.setProperty("label", "(" + i + ")"); | |
nodes.add(node); | |
} | |
Relationship relationshipA = nodes.get(0).createRelationshipTo(nodes.get(1), MyTypes.POINTS_TO); | |
relationshipA.setProperty("edgelabel", "A"); | |
Relationship relationshipB = nodes.get(1).createRelationshipTo(nodes.get(2), MyTypes.POINTS_TO); | |
relationshipB.setProperty("edgelabel", "B"); | |
tx.success(); | |
} finally { | |
tx.finish(); | |
} | |
graphDb.shutdown(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment