Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Graph.addEdge()


    FramedGraphFactory factory = new FramedGraphFactory(new TypedGraphModuleBuilder().withClass(A.class).withClass(B.class)
        .withClass(C.class).build());
    FramedGraph<Graph> framedGraph = factory.create(graph);
    Vertex v1 = graph.addVertex(null);
    Vertex v2 = graph.addVertex(null);
    Edge cE = graph.addEdge(null, v1, v2, "label");
    cE.setProperty("type", "C");
    Base c = framedGraph.getEdge(cE.getId(), Direction.OUT, Base.class);
    assertTrue(c instanceof C);
  }
View Full Code Here


        FramedGraph<Graph> framedGraph = factory.create(graph);
        Vertex v1 = graph.addVertex(null);

        Vertex v2 = graph.addVertex(null);
        v2.setProperty("type", "A");
        Edge cE = graph.addEdge(null, v1, v2, "label");
        cE.setProperty("type", "C");
        Base c = framedGraph.getEdge(cE.getId(), Direction.OUT, Base.class);
        assertTrue(c instanceof C);
        assertTrue(((C) c).getInVertex() instanceof A);
View Full Code Here

    public void testElementClasses() throws Exception {
        Graph graph = this.generateGraph();
        Vertex v1 = graph.addVertex(null);
        Vertex v2 = graph.addVertex(null);
        Edge e = graph.addEdge(null, v1, v2, "knows");

        assertTrue(v1 instanceof IdVertex);
        assertTrue(e instanceof IdEdge);

        Iterator<Edge> outE = v1.getEdges(Direction.OUT).iterator();
View Full Code Here

        assertEquals(36, id.length());
        assertEquals(5, id.split("-").length);

        Vertex v2 = graph.addVertex(null);
        Edge e = graph.addEdge(null, v, v2, "knows");

        id = (String) e.getId();
        assertEquals(36, id.length());
        assertEquals(5, id.split("-").length);
        graph.shutdown();
View Full Code Here

            assertTrue(false);
        } catch (UnsupportedOperationException e) {
            assertTrue(true);
        }
        try {
            graph.addEdge(null, null, null, "knows");
            assertTrue(false);
        } catch (UnsupportedOperationException e) {
            assertTrue(true);
        }
        try {
View Full Code Here

            Vertex[] vertices = new Vertex[2];
            for (int i = 0; i < 2; i++) {
                vertices[i] = graph.getVertex(quad[i]);
                if (vertices[i] == null) vertices[i] = graph.addVertex(quad[i]);
            }
            Edge edge = graph.addEdge(null, vertices[0], vertices[1], quad[2]);
            edge.setProperty("annotation", quad[3]);
            counter++;
        }
        assertEquals(numEdges, BaseTest.count(tg.getEdges()));
View Full Code Here

            Vertex[] vertices = new Vertex[2];
            for (int i = 0; i < 2; i++) {
                vertices[i] = graph.getVertex(quad[i]);
                if (vertices[i] == null) vertices[i] = graph.addVertex(quad[i]);
            }
            Edge edge = graph.addEdge(null, vertices[0], vertices[1], quad[2]);
            edge.setProperty("annotation", quad[3]);
            counter++;
        }
        assertEquals(numEdges, BaseTest.count(tg.getEdges()));
View Full Code Here

        marko.setProperty("age", 32);
        Vertex stephen = graph.addVertex(3);
        stephen.setProperty("name", "stephen");
        stephen.setProperty("weight", 160.42);
        stephen.setProperty("male", true);
        Edge e = graph.addEdge(null, marko, stephen, "knows");
        e.setProperty("weight", 0.2);
        e.setProperty("type", "coworker");

        ByteArrayOutputStream bytes1 = new ByteArrayOutputStream();
        DataOutput out = new DataOutputStream(bytes1);
View Full Code Here

                // validate that the vertexes are present before creating the edge
                final Vertex out = graph.getVertex(outV);
                final Vertex in = graph.getVertex(inV);
                if (null != out && null != in) {
                    // in/out vertexes are found so edge can be created
                    edge = graph.addEdge(id, out, in, label);
                } else {
                    final JSONObject error = generateErrorObjectJsonFail(new Exception("One or both of the vertices for the edge does not exist in the graph."));
                    throw new WebApplicationException(Response.status(Status.CONFLICT).entity(error).build());
                }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.