Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Graph


        super(graphTest);
    }

    public void testTinkerGraph() throws Exception {
        double totalTime = 0.0d;
        Graph graph = graphTest.generateGraph();
        GraphMLReader.inputGraph(graph, GraphMLReader.class.getResourceAsStream("graph-example-2.xml"));

        for (int i = 0; i < TOTAL_RUNS; i++) {
            this.stopWatch();
            int counter = 0;
            for (final Vertex vertex : graph.getVertices()) {
                counter++;
                for (final Edge edge : vertex.getEdges(Direction.OUT)) {
                    counter++;
                    final Vertex vertex2 = edge.getVertex(Direction.IN);
                    counter++;
                    for (final Edge edge2 : vertex2.getEdges(Direction.OUT)) {
                        counter++;
                        final Vertex vertex3 = edge2.getVertex(Direction.IN);
                        counter++;
                        for (final Edge edge3 : vertex3.getEdges(Direction.OUT)) {
                            counter++;
                            edge3.getVertex(Direction.OUT);
                            counter++;
                        }
                    }
                }
            }
            double currentTime = this.stopWatch();
            totalTime = totalTime + currentTime;
            BaseTest.printPerformance(graph.toString(), counter, "TinkerGraph elements touched", currentTime);
            graph.shutdown();
        }
        BaseTest.printPerformance("TinkerGraph", 1, "TinkerGraph experiment average", totalTime / (double) TOTAL_RUNS);
    }
View Full Code Here


* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class ElementHelperTest extends BaseTest {

    public void testCopyElementProperties() {
        Graph graph = new TinkerGraph();
        Vertex v = graph.addVertex(null);
        v.setProperty("name", "marko");
        v.setProperty("age", 31);
        Vertex u = graph.addVertex(null);
        assertEquals(u.getPropertyKeys().size(), 0);
        ElementHelper.copyProperties(v, u);
        assertEquals(u.getPropertyKeys().size(), 2);
        assertEquals(u.getProperty("name"), "marko");
        assertEquals(u.getProperty("age"), 31);
View Full Code Here

        assertEquals(u.getProperty("name"), "marko");
        assertEquals(u.getProperty("age"), 31);
    }

    public void testRemoveProperties() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        Vertex vertex = graph.getVertex(1);
        assertEquals(vertex.getProperty("name"), "marko");
        assertEquals(vertex.getProperty("age"), 29);
        assertEquals(vertex.getPropertyKeys().size(), 2);

        ElementHelper.removeProperties(Arrays.asList((Element) vertex));
View Full Code Here

        assertNull(vertex.getProperty("age"));
        assertEquals(vertex.getPropertyKeys().size(), 0);
    }

    public void testRemoveProperty() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        ElementHelper.removeProperty("name", (Iterable) graph.getVertices());
        for (Vertex v : graph.getVertices()) {
            assertNull(v.getProperty("name"));
        }
    }
View Full Code Here

            assertNull(v.getProperty("name"));
        }
    }

    public void testRenameProperty() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        ElementHelper.renameProperty("name", "name2", (Iterable) graph.getVertices());
        for (Vertex v : graph.getVertices()) {
            assertNull(v.getProperty("name"));
            assertNotNull(v.getProperty("name2"));
            String name2 = (String) v.getProperty("name2");
            assertTrue(name2.equals("marko") || name2.equals("josh") || name2.equals("vadas") || name2.equals("ripple") || name2.equals("lop") || name2.equals("peter"));
        }
View Full Code Here

            assertTrue(name2.equals("marko") || name2.equals("josh") || name2.equals("vadas") || name2.equals("ripple") || name2.equals("lop") || name2.equals("peter"));
        }
    }

    public void testTypecastProperty() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        for (Edge e : graph.getEdges()) {
            assertTrue(e.getProperty("weight") instanceof Float);
        }
        ElementHelper.typecastProperty("weight", Double.class, (Iterable) graph.getEdges());
        for (Edge e : graph.getEdges()) {
            assertTrue(e.getProperty("weight") instanceof Double);
        }
    }
View Full Code Here

            assertTrue(e.getProperty("weight") instanceof Double);
        }
    }

    public void testHaveEqualProperties() {
        Graph graph = new TinkerGraph();
        Vertex a = graph.addVertex(null);
        Vertex b = graph.addVertex(null);
        Vertex c = graph.addVertex(null);
        Vertex d = graph.addVertex(null);

        a.setProperty("name", "marko");
        a.setProperty("age", 31);
        b.setProperty("name", "marko");
        b.setProperty("age", 31);
View Full Code Here

        assertFalse(ElementHelper.haveEqualProperties(a, c));

    }

    public void testGetProperties() {
        Graph graph = TinkerGraphFactory.createTinkerGraph();
        Vertex vertex = graph.getVertex(1);
        Map<String, Object> map = ElementHelper.getProperties(vertex);
        assertEquals(map.size(), 2);
        assertEquals(map.get("name"), "marko");
        assertEquals(map.get("age"), 29);
View Full Code Here

        assertEquals(vertex.getProperty("name"), "marko");
    }

    public void testSetProperties() {
        Graph graph = new TinkerGraph();
        Vertex vertex = graph.addVertex(null);
        Map map = new HashMap();
        map.put("name", "pierre");
        ElementHelper.setProperties(vertex, map);
        assertEquals(vertex.getPropertyKeys().size(), 1);
        assertEquals(vertex.getProperty("name"), "pierre");
View Full Code Here


    }

    public void testSetPropertiesVarArgs() {
        Graph graph = new TinkerGraph();
        Vertex vertex = graph.addVertex(null);
        ElementHelper.setProperties(vertex, "name", "pierre");
        assertEquals(vertex.getPropertyKeys().size(), 1);
        assertEquals(vertex.getProperty("name"), "pierre");

        ElementHelper.setProperties(vertex, "name", "dewilde", "country", "belgium", "age", 50);
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.Graph

Copyright © 2018 www.massapicom. 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.