use of ai.grakn.graql.analytics.PathsQuery in project grakn by graknlabs.
the class GraqlTest method testPaths.
@Test
public void testPaths() throws InvalidKBException {
addSchemaAndEntities();
try (GraknTx graph = session.open(GraknTxType.WRITE)) {
PathsQuery query = graph.graql().parse("compute paths from '" + entityId1 + "' to '" + entityId2 + "';");
List<List<Concept>> path = query.execute();
assertEquals(1, path.size());
List<String> result = path.get(0).stream().map(Concept::getId).map(ConceptId::getValue).collect(Collectors.toList());
List<String> expected = Lists.newArrayList(entityId1, relationId12, entityId2);
assertEquals(expected, result);
}
}
use of ai.grakn.graql.analytics.PathsQuery in project grakn by graknlabs.
the class TinkerComputeQueryRunner method run.
public ComputeJob<Optional<List<Concept>>> run(PathQuery query) {
PathsQuery pathsQuery = tx.graql().compute().paths();
if (query.isAttributeIncluded())
pathsQuery = pathsQuery.includeAttribute();
pathsQuery = pathsQuery.from(query.from()).to(query.to()).in(query.subLabels());
return run(pathsQuery).map(result -> result.stream().findAny());
}
Aggregations