Search in sources :

Example 1 with WeightedPath

use of com.baidu.hugegraph.structure.traverser.WeightedPath in project incubator-hugegraph-toolchain by apache.

the class WeightedShortestPathApiTest method testWeightedShortestPath.

@Test
public void testWeightedShortestPath() {
    WeightedPath weightedPath = weightedShortestPathAPI.get("A", "Z", Direction.BOTH, null, "weight", -1, 0, -1, false);
    Assert.assertTrue(weightedPath.vertices().isEmpty());
    Assert.assertEquals(0.5D, weightedPath.path().weight(), Double.MIN_VALUE);
    Assert.assertEquals(ImmutableList.of("A", "H", "I", "J", "Z"), weightedPath.path().vertices());
}
Also used : WeightedPath(com.baidu.hugegraph.structure.traverser.WeightedPath) Test(org.junit.Test)

Example 2 with WeightedPath

use of com.baidu.hugegraph.structure.traverser.WeightedPath in project incubator-hugegraph-toolchain by apache.

the class WeightedShortestPathApiTest method testWeightedShortestPathWithVertex.

@Test
public void testWeightedShortestPathWithVertex() {
    WeightedPath weightedPath = weightedShortestPathAPI.get("A", "Z", Direction.BOTH, null, "weight", -1, 0, -1, true);
    Assert.assertEquals(5, weightedPath.vertices().size());
    List<Object> expected = ImmutableList.of("A", "H", "I", "J", "Z");
    for (Vertex vertex : weightedPath.vertices()) {
        Assert.assertTrue(expected.contains(vertex.id()));
    }
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) WeightedPath(com.baidu.hugegraph.structure.traverser.WeightedPath) Test(org.junit.Test)

Example 3 with WeightedPath

use of com.baidu.hugegraph.structure.traverser.WeightedPath in project incubator-hugegraph-toolchain by apache.

the class WeightedShortestPathApiTest method testWeightedShortestPathWithLabel.

@Test
public void testWeightedShortestPathWithLabel() {
    WeightedPath weightedPath = weightedShortestPathAPI.get("A", "Z", Direction.BOTH, "link", "weight", -1, 0, -1, false);
    Assert.assertTrue(weightedPath.vertices().isEmpty());
    Assert.assertEquals(0.5D, weightedPath.path().weight(), Double.MIN_VALUE);
    Assert.assertEquals(ImmutableList.of("A", "H", "I", "J", "Z"), weightedPath.path().vertices());
    weightedPath = weightedShortestPathAPI.get("A", "Z", Direction.BOTH, "relateTo", "weight", -1, 0, -1, false);
    Assert.assertTrue(weightedPath.vertices().isEmpty());
    Assert.assertEquals(6.3999999999999995D, weightedPath.path().weight(), Double.MIN_VALUE);
    Assert.assertEquals(ImmutableList.of("A", "Q", "R", "Z"), weightedPath.path().vertices());
}
Also used : WeightedPath(com.baidu.hugegraph.structure.traverser.WeightedPath) Test(org.junit.Test)

Example 4 with WeightedPath

use of com.baidu.hugegraph.structure.traverser.WeightedPath in project incubator-hugegraph-toolchain by apache.

the class WeightedShortestPathApiTest method testWeightedShortestPathWithDegree.

@Test
public void testWeightedShortestPathWithDegree() {
    WeightedPath weightedPath = weightedShortestPathAPI.get("A", "Z", Direction.OUT, null, "weight", 1L, 0L, -1L, false);
    Assert.assertTrue(weightedPath.vertices().isEmpty());
    Assert.assertEquals(2.0D, weightedPath.path().weight(), Double.MIN_VALUE);
    Assert.assertEquals(ImmutableList.of("A", "B", "C", "D", "Z"), weightedPath.path().vertices());
}
Also used : WeightedPath(com.baidu.hugegraph.structure.traverser.WeightedPath) Test(org.junit.Test)

Example 5 with WeightedPath

use of com.baidu.hugegraph.structure.traverser.WeightedPath in project incubator-hugegraph-toolchain by apache.

the class WeightedShortestPathApiTest method testWeightedShortestPathWithDirection.

@Test
public void testWeightedShortestPathWithDirection() {
    WeightedPath weightedPath = weightedShortestPathAPI.get("A", "Z", Direction.OUT, null, "weight", -1, 0, -1, false);
    Assert.assertTrue(weightedPath.vertices().isEmpty());
    Assert.assertEquals(2.0D, weightedPath.path().weight(), Double.MIN_VALUE);
    Assert.assertEquals(ImmutableList.of("A", "B", "C", "D", "Z"), weightedPath.path().vertices());
}
Also used : WeightedPath(com.baidu.hugegraph.structure.traverser.WeightedPath) Test(org.junit.Test)

Aggregations

WeightedPath (com.baidu.hugegraph.structure.traverser.WeightedPath)5 Test (org.junit.Test)5 Vertex (com.baidu.hugegraph.structure.graph.Vertex)1