Search in sources :

Example 21 with Edge

use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.

the class EdgeTest method testGetEdgesByVertexIdWithLimit2.

@Test
public void testGetEdgesByVertexIdWithLimit2() {
    BaseClientTest.initEdge();
    Object markoId = getVertexId("person", "name", "marko");
    List<Edge> edges = graph().getEdges(markoId, 2);
    Assert.assertEquals(2, edges.size());
    for (Edge edge : edges) {
        Assert.assertEquals(markoId, edge.sourceId());
    }
}
Also used : Edge(com.baidu.hugegraph.structure.graph.Edge) Test(org.junit.Test) BaseClientTest(com.baidu.hugegraph.BaseClientTest)

Example 22 with Edge

use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.

the class EdgeTest method testName.

@Test
public void testName() {
    BaseClientTest.initEdge();
    Object markoId = getVertexId("person", "name", "marko");
    List<Edge> edges = graph().getEdges(markoId, Direction.OUT, "knows");
    Assert.assertEquals(2, edges.size());
    Edge edge1 = edges.get(0);
    Edge edge2 = edges.get(1);
    Date date1 = DateUtil.parse((String) edge1.property("date"));
    Date date2 = DateUtil.parse((String) edge2.property("date"));
    String name1 = edge1.name();
    String name2 = edge2.name();
    if (date1.before(date2)) {
        Assert.assertTrue(name1.compareTo(name2) < 0);
    } else {
        Assert.assertTrue(name1.compareTo(name2) >= 0);
    }
}
Also used : Edge(com.baidu.hugegraph.structure.graph.Edge) Date(java.util.Date) Test(org.junit.Test) BaseClientTest(com.baidu.hugegraph.BaseClientTest)

Example 23 with Edge

use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.

the class EdgeTest method testGetEdgesByVertexIdDirectionWithLimit1.

@Test
public void testGetEdgesByVertexIdDirectionWithLimit1() {
    BaseClientTest.initEdge();
    Object joshId = getVertexId("person", "name", "josh");
    List<Edge> edges = graph().getEdges(joshId, Direction.OUT, 1);
    Assert.assertEquals(1, edges.size());
    for (Edge edge : edges) {
        // TODO: Whether need to add direction property in Edge?
        Assert.assertEquals(joshId, edge.sourceId());
    }
    edges = graph().getEdges(joshId, Direction.IN, 1);
    Assert.assertEquals(1, edges.size());
    for (Edge edge : edges) {
        Assert.assertEquals(joshId, edge.targetId());
    }
}
Also used : Edge(com.baidu.hugegraph.structure.graph.Edge) Test(org.junit.Test) BaseClientTest(com.baidu.hugegraph.BaseClientTest)

Example 24 with Edge

use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.

the class EdgeTest method testAddEdgeWithMapProperties.

@Test
public void testAddEdgeWithMapProperties() {
    Vertex peter = getVertex("person", "name", "peter");
    Vertex lop = getVertex("software", "name", "lop");
    Map<String, Object> properties = ImmutableMap.of("date", "2017-03-24", "city", "HongKong");
    Edge created = graph().addEdge(peter, "created", lop, properties);
    Map<String, Object> props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "city", "HongKong");
    Assert.assertEquals(props, created.properties());
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) Edge(com.baidu.hugegraph.structure.graph.Edge) Test(org.junit.Test) BaseClientTest(com.baidu.hugegraph.BaseClientTest)

Example 25 with Edge

use of com.baidu.hugegraph.structure.graph.Edge in project incubator-hugegraph-toolchain by apache.

the class EdgeTest method testGetEdgesByVertexIdDirectionLabelWithLimit1.

@Test
public void testGetEdgesByVertexIdDirectionLabelWithLimit1() {
    BaseClientTest.initEdge();
    Object joshId = getVertexId("person", "name", "josh");
    List<Edge> edges = graph().getEdges(joshId, Direction.OUT, "created", 1);
    Assert.assertEquals(1, edges.size());
    for (Edge edge : edges) {
        Assert.assertEquals(joshId, edge.sourceId());
        Assert.assertEquals("created", edge.label());
    }
    edges = graph().getEdges(joshId, Direction.IN, "knows", 1);
    Assert.assertEquals(1, edges.size());
    for (Edge edge : edges) {
        Assert.assertEquals(joshId, edge.targetId());
        Assert.assertEquals("knows", edge.label());
    }
}
Also used : Edge(com.baidu.hugegraph.structure.graph.Edge) Test(org.junit.Test) BaseClientTest(com.baidu.hugegraph.BaseClientTest)

Aggregations

Edge (com.baidu.hugegraph.structure.graph.Edge)103 Test (org.junit.Test)73 Vertex (com.baidu.hugegraph.structure.graph.Vertex)33 ArrayList (java.util.ArrayList)22 BaseClientTest (com.baidu.hugegraph.BaseClientTest)20 BatchEdgeRequest (com.baidu.hugegraph.structure.graph.BatchEdgeRequest)12 HugeClient (com.baidu.hugegraph.driver.HugeClient)10 Path (com.baidu.hugegraph.structure.graph.Path)9 Result (com.baidu.hugegraph.structure.gremlin.Result)8 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)7 RestResult (com.baidu.hugegraph.rest.RestResult)5 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)5 GraphManager (com.baidu.hugegraph.driver.GraphManager)4 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)4 GraphView (com.baidu.hugegraph.entity.query.GraphView)4 Edges (com.baidu.hugegraph.structure.graph.Edges)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 GremlinResult (com.baidu.hugegraph.entity.query.GremlinResult)3 TypedResult (com.baidu.hugegraph.entity.query.TypedResult)3