public class Example01_CreateVertex {
private static Logger log = Logger.getLogger(Example01_CreateVertex.class);
public static void main(String[] args) throws Exception {
Graph graph = Util.createLightGraph();
Visibility visA = new Visibility("a");
Visibility visB = new Visibility("b");
Visibility visAandB = new Visibility("a&b");
Authorizations authA = new AccumuloAuthorizations("a");
/* add a vertex with properties */
Vertex v = graph.prepareVertex("Micky Mouse", visAandB)
.setProperty("name", "Micky", visA)
.setProperty("surname", "Mouse", visB).save(authA);
/* add 2 vertex and the edge */
Vertex v1 = graph.addVertex("Micky Mouse", visA, authA);
Vertex v2 = graph.addVertex("Donald Duck", visA, authA);
Edge e = graph.addEdge(v1, v2, "is_friend", visA, authA);
/* add a edge */
graph.addEdge("edgeId", v1, v, "equal", visA, authA);
System.out.println("--------------- -> end add data");
/* read edges */
Iterable<Edge> edges = v1.getEdges(Direction.BOTH, authA);
for (Edge es : edges) {
System.out.println(es.getLabel());
} // for
/* query a vertex */
Iterable<Vertex> vertices = graph.query("Micky Mouse", authA).vertices();
Iterator<Vertex> ed = vertices.iterator();
System.out.println("--------------- -> end query graph");
graph.flush();
} // main
} // class