Examples of TinkerGraph


Examples of com.tinkerpop.blueprints.impls.tg.TinkerGraph

    }

    @Test(expected = IllegalArgumentException.class)
    public void inputGraphCompactFullCycleBroken() throws IOException {
        TinkerGraph graph = TinkerGraphFactory.createTinkerGraph();

        ByteArrayOutputStream stream = new ByteArrayOutputStream();

        Set<String> edgeKeys = new HashSet<String>();
        edgeKeys.add(GraphSONTokens._IN_V);
        edgeKeys.add(GraphSONTokens._OUT_V);
        edgeKeys.add(GraphSONTokens._LABEL);

        Set<String> vertexKeys = new HashSet<String>();

        GraphSONWriter writer = new GraphSONWriter(graph);
        writer.outputGraph(stream, vertexKeys, edgeKeys, GraphSONMode.COMPACT);

        stream.flush();
        stream.close();

        String jsonString = new String(stream.toByteArray());

        byte[] bytes = jsonString.getBytes();
        InputStream inputStream = new ByteArrayInputStream(bytes);

        TinkerGraph emptyGraph = new TinkerGraph();
        GraphSONReader.inputGraph(emptyGraph, inputStream);

    }
View Full Code Here

Examples of com.tinkerpop.blueprints.impls.tg.TinkerGraph

    private static final String LABEL = "label";

    @Test
    public void exampleGMLGetsCorrectNumberOfElements() throws IOException {
        TinkerGraph graph = new TinkerGraph();

        GMLReader.inputGraph(graph, GMLReader.class.getResourceAsStream("example.gml"));

        Assert.assertEquals(3, getIterableCount(graph.getVertices()));
        Assert.assertEquals(3, getIterableCount(graph.getEdges()));
    }
View Full Code Here

Examples of com.tinkerpop.blueprints.impls.tg.TinkerGraph

        Assert.assertEquals(3, getIterableCount(graph.getEdges()));
    }

    @Test
    public void exampleGMLGetsCorrectTopology() throws IOException {
        TinkerGraph graph = new TinkerGraph();

        GMLReader.inputGraph(graph, GMLReader.class.getResourceAsStream("example.gml"));

        Vertex v1 = graph.getVertex(1);
        Vertex v2 = graph.getVertex(2);
        Vertex v3 = graph.getVertex(3);

        Iterable<Edge> out1 = v1.getEdges(Direction.OUT);
        Edge e1 = out1.iterator().next();
        Assert.assertEquals(v2, e1.getVertex(Direction.IN));
View Full Code Here

Examples of com.tinkerpop.blueprints.impls.tg.TinkerGraph

    }

    @Test
    public void exampleGMLGetsCorrectProperties() throws IOException {
        TinkerGraph graph = new TinkerGraph();

        GMLReader.inputGraph(graph, GMLReader.class.getResourceAsStream("example.gml"));

        Vertex v1 = graph.getVertex(1);
        Assert.assertEquals("Node 1", v1.getProperty(LABEL));

        Vertex v2 = graph.getVertex(2);
        Assert.assertEquals("Node 2", v2.getProperty(LABEL));

        Vertex v3 = graph.getVertex(3);
        Assert.assertEquals("Node 3", v3.getProperty(LABEL));

        Iterable<Edge> out1 = v1.getEdges(Direction.OUT);
        Edge e1 = out1.iterator().next();
        Assert.assertEquals("Edge from node 1 to node 2", e1.getLabel());
View Full Code Here

Examples of com.tinkerpop.blueprints.impls.tg.TinkerGraph

    }

    @Test(expected = IOException.class)
    public void malformedThrowsIOException() throws IOException {
        GMLReader.inputGraph(new TinkerGraph(), GMLReader.class.getResourceAsStream("malformed.gml"));
    }
View Full Code Here

Examples of com.tinkerpop.blueprints.impls.tg.TinkerGraph

        GMLReader.inputGraph(new TinkerGraph(), GMLReader.class.getResourceAsStream("malformed.gml"));
    }

    @Test
    public void example2GMLTestingMapParsing() throws IOException {
        TinkerGraph graph = new TinkerGraph();

        GMLReader.inputGraph(graph, GMLReader.class.getResourceAsStream("example2.gml"));

        Assert.assertEquals(2, getIterableCount(graph.getVertices()));
        Assert.assertEquals(1, getIterableCount(graph.getEdges()));

        Object property = graph.getVertex(1).getProperty(GMLTokens.GRAPHICS);
        Assert.assertTrue(property instanceof Map<?, ?>);

        @SuppressWarnings("unchecked")
        Map<String, Object> map = (Map<String, Object>) property;
        Assert.assertEquals(5, map.size());
View Full Code Here

Examples of com.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph

    @Override
    public boolean nextKeyValue() throws IOException {
        if (!this.lineRecordReader.nextKeyValue())
            return false;

        final TinkerGraph g = TinkerGraph.open();

        final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> DetachedVertex.addTo(g, detachedVertex);
        final Function<DetachedEdge, Edge> edgeMaker = detachedEdge -> DetachedEdge.addTo(g, detachedEdge);

        final TinkerVertex v;
View Full Code Here

Examples of com.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph

        assertEquals("some", deserializedInnerInnerMap.get("y"));
    }

    @Test
    public void serializeToMapWithElementForKey() throws Exception {
        final TinkerGraph g = TinkerFactory.createClassic();
        final Map<Vertex, Integer> map = new HashMap<>();
        map.put(g.V().<Vertex>has("name", Compare.eq, "marko").next(), 1000);

        final ResponseMessage response = convert(map);
        assertCommon(response);

        final Map<Vertex, Integer> deserializedMap = (Map<Vertex, Integer>) response.getResult().getData();
View Full Code Here

Examples of com.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph

        assertEquals("some", deserializedInnerInnerMap.get("y"));
    }

    @Test
    public void serializeToJsonMapWithElementForKey() throws Exception {
        final TinkerGraph g = TinkerFactory.createClassic();
        final Map<Vertex, Integer> map = new HashMap<>();
        map.put(g.V().<Vertex>has("name", Compare.eq, "marko").next(), 1000);

        final ResponseMessage response = convert(map);
        assertCommon(response);

        final Map<String, Integer> deserializedMap = (Map<String, Integer>) response.getResult().getData();
View Full Code Here

Examples of com.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph

    private void inflateTinkerVertex() {
        try {
            final ByteArrayInputStream bis = new ByteArrayInputStream(this.getValue().getBytes());
            final KryoReader reader = KryoReader.build().create();
            final TinkerGraph tinkerGraph = TinkerGraph.open();
            reader.readGraph(bis, tinkerGraph);
            bis.close();
            this.tinkerVertex = (TinkerVertex) tinkerGraph.v(tinkerGraph.variables().get(VERTEX_ID).get());
        } catch (final Exception e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
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.