use of com.baidu.hugegraph.structure.traverser.TemplatePathsRequest in project incubator-hugegraph-toolchain by apache.
the class TemplatePathsApiTest method testTemplatePathsWithProperties.
@Test
public void testTemplatePathsWithProperties() {
TemplatePathsRequest.Builder builder = TemplatePathsRequest.builder();
builder.sources().ids(1);
builder.targets().ids(10);
builder.steps().direction(Direction.OUT).labels("relateTo").maxTimes(3);
builder.steps().direction(Direction.OUT).labels("relateTo").maxTimes(3);
builder.steps().direction(Direction.IN).labels("relateTo").maxTimes(3);
builder.withRing(true);
TemplatePathsRequest request = builder.build();
PathsWithVertices pathsWithVertices = templatePathsAPI.post(request);
List<PathsWithVertices.Paths> paths = pathsWithVertices.paths();
Assert.assertEquals(4, paths.size());
List<List<Object>> expected = ImmutableList.of(ImmutableList.of(1, 16, 17, 10), ImmutableList.of(1, 16, 17, 16, 17, 10), ImmutableList.of(1, 16, 17, 16, 17, 16, 17, 10), ImmutableList.of(1, 16, 17, 16, 17, 16, 17, 16, 17, 10));
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expected.contains(path.objects()));
}
builder = TemplatePathsRequest.builder();
builder.sources().ids(1);
builder.targets().ids(10);
builder.steps().direction(Direction.OUT).labels("relateTo").properties("weight", "P.gt(0.4)").maxTimes(3);
builder.steps().direction(Direction.OUT).labels("relateTo").properties("weight", "P.gt(0.4)").maxTimes(3);
builder.steps().direction(Direction.IN).labels("relateTo").properties("weight", "P.gt(0.4)").maxTimes(3);
builder.withRing(true);
request = builder.build();
pathsWithVertices = templatePathsAPI.post(request);
paths = pathsWithVertices.paths();
Assert.assertEquals(1, paths.size());
expected = ImmutableList.of(ImmutableList.of(1, 16, 17, 10));
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expected.contains(path.objects()));
}
}
use of com.baidu.hugegraph.structure.traverser.TemplatePathsRequest in project incubator-hugegraph-toolchain by apache.
the class TemplatePathsApiTest method testTemplatePathsWithVertex.
@Test
public void testTemplatePathsWithVertex() {
TemplatePathsRequest.Builder builder = TemplatePathsRequest.builder();
builder.sources().ids(1);
builder.targets().ids(10);
builder.steps().direction(Direction.OUT).labels("relateTo").maxTimes(3);
builder.steps().direction(Direction.OUT).labels("relateTo").maxTimes(3);
builder.steps().direction(Direction.IN).labels("relateTo").maxTimes(3);
builder.withVertex(true);
TemplatePathsRequest request = builder.build();
PathsWithVertices pathsWithVertices = templatePathsAPI.post(request);
List<PathsWithVertices.Paths> paths = pathsWithVertices.paths();
Assert.assertEquals(1, paths.size());
List<Object> expectedIds = ImmutableList.of(1, 16, 17, 10);
List<List<Object>> expectedPath = ImmutableList.of(expectedIds);
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expectedPath.contains(path.objects()));
}
Set<Vertex> vertices = pathsWithVertices.vertices();
Assert.assertEquals(4, vertices.size());
for (Vertex v : vertices) {
Assert.assertTrue(expectedIds.contains(v.id()));
}
}
use of com.baidu.hugegraph.structure.traverser.TemplatePathsRequest in project incubator-hugegraph-toolchain by apache.
the class TemplatePathsApiTest method testTemplatePathsWithRing.
@Test
public void testTemplatePathsWithRing() {
TemplatePathsRequest.Builder builder = TemplatePathsRequest.builder();
builder.sources().ids(1);
builder.targets().ids(10);
builder.steps().direction(Direction.OUT).labels("relateTo").maxTimes(3);
builder.steps().direction(Direction.OUT).labels("relateTo").maxTimes(3);
builder.steps().direction(Direction.IN).labels("relateTo").maxTimes(3);
TemplatePathsRequest request = builder.build();
PathsWithVertices pathsWithVertices = templatePathsAPI.post(request);
List<PathsWithVertices.Paths> paths = pathsWithVertices.paths();
Assert.assertEquals(1, paths.size());
List<List<Object>> expected = ImmutableList.of(ImmutableList.of(1, 16, 17, 10));
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expected.contains(path.objects()));
}
builder = TemplatePathsRequest.builder();
builder.sources().ids(1);
builder.targets().ids(10);
builder.steps().direction(Direction.OUT).labels("relateTo").maxTimes(3);
builder.steps().direction(Direction.OUT).labels("relateTo").maxTimes(3);
builder.steps().direction(Direction.IN).labels("relateTo").maxTimes(3);
builder.withRing(true);
request = builder.build();
pathsWithVertices = templatePathsAPI.post(request);
paths = pathsWithVertices.paths();
Assert.assertEquals(4, paths.size());
expected = ImmutableList.of(ImmutableList.of(1, 16, 17, 10), ImmutableList.of(1, 16, 17, 16, 17, 10), ImmutableList.of(1, 16, 17, 16, 17, 16, 17, 10), ImmutableList.of(1, 16, 17, 16, 17, 16, 17, 16, 17, 10));
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expected.contains(path.objects()));
}
}
use of com.baidu.hugegraph.structure.traverser.TemplatePathsRequest in project incubator-hugegraph-toolchain by apache.
the class TemplatePathsApiTest method testTemplatePathsWithLabel.
@Test
public void testTemplatePathsWithLabel() {
TemplatePathsRequest.Builder builder = TemplatePathsRequest.builder();
builder.sources().ids(1);
builder.targets().ids(10);
builder.steps().direction(Direction.OUT).labels("link").maxTimes(3);
builder.steps().direction(Direction.OUT).labels("link").maxTimes(3);
builder.steps().direction(Direction.IN).labels("link").maxTimes(3);
TemplatePathsRequest request = builder.build();
PathsWithVertices pathsWithVertices = templatePathsAPI.post(request);
List<PathsWithVertices.Paths> paths = pathsWithVertices.paths();
Assert.assertEquals(3, paths.size());
List<List<Object>> expected = ImmutableList.of(ImmutableList.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), ImmutableList.of(1, 11, 12, 13, 14, 15, 10), ImmutableList.of(1, 16, 17, 10));
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expected.contains(path.objects()));
}
builder = TemplatePathsRequest.builder();
builder.sources().ids(1);
builder.targets().ids(10);
builder.steps().direction(Direction.OUT).labels("relateTo").maxTimes(3);
builder.steps().direction(Direction.OUT).labels("relateTo").maxTimes(3);
builder.steps().direction(Direction.IN).labels("relateTo").maxTimes(3);
request = builder.build();
pathsWithVertices = templatePathsAPI.post(request);
paths = pathsWithVertices.paths();
Assert.assertEquals(1, paths.size());
expected = ImmutableList.of(ImmutableList.of(1, 16, 17, 10));
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expected.contains(path.objects()));
}
}
use of com.baidu.hugegraph.structure.traverser.TemplatePathsRequest in project incubator-hugegraph-toolchain by apache.
the class TemplatePathsApiTest method testTemplatePaths.
@Test
public void testTemplatePaths() {
TemplatePathsRequest.Builder builder = TemplatePathsRequest.builder();
builder.sources().ids(1);
builder.targets().ids(10);
builder.steps().direction(Direction.OUT).maxTimes(3);
builder.steps().direction(Direction.OUT).maxTimes(3);
builder.steps().direction(Direction.IN).maxTimes(3);
TemplatePathsRequest request = builder.build();
PathsWithVertices pathsWithVertices = templatePathsAPI.post(request);
List<PathsWithVertices.Paths> paths = pathsWithVertices.paths();
Assert.assertEquals(3, paths.size());
List<List<Object>> expected = ImmutableList.of(ImmutableList.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), ImmutableList.of(1, 11, 12, 13, 14, 15, 10), ImmutableList.of(1, 16, 17, 10));
for (PathsWithVertices.Paths path : paths) {
Assert.assertTrue(expected.contains(path.objects()));
}
}
Aggregations