forked from tinkerpop/blueprints
-
Notifications
You must be signed in to change notification settings - Fork 0
Code Examples
okram edited this page Dec 1, 2010
·
16 revisions
This section will provide a collection of code examples that work with the Blueprints graph API. The in-memory TinkerGraph database will be used throughout the examples. Please feel free to alter the graph constructor to work with different graph databases. These code examples can be found in the main Blueprints distribution at this location.
Create a graph. Add two vertices. Set the name
property of each vertex. Create an knows
edge between the two vertices. Shutdown the graph.
Graph graph = new TinkerGraph();
Vertex a = graph.addVertex(null);
Vertex b = graph.addVertex(null);
a.setProperty("name", "marko");
a.setProperty("name", "peter");
Edge e = graph.addEdge(null, a, b, "knows");
graph.shutdown();