use of com.baidu.hugegraph.traversal.algorithm.PathsTraverser in project incubator-hugegraph by apache.
the class PathsAPI method get.
@GET
@Timed
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String get(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("source") String source, @QueryParam("target") String target, @QueryParam("direction") String direction, @QueryParam("label") String edgeLabel, @QueryParam("max_depth") int depth, @QueryParam("max_degree") @DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree, @QueryParam("capacity") @DefaultValue(DEFAULT_CAPACITY) long capacity, @QueryParam("limit") @DefaultValue(DEFAULT_PATHS_LIMIT) long limit) {
LOG.debug("Graph [{}] get paths from '{}', to '{}' with " + "direction {}, edge label {}, max depth '{}', " + "max degree '{}', capacity '{}' and limit '{}'", graph, source, target, direction, edgeLabel, depth, maxDegree, capacity, limit);
Id sourceId = VertexAPI.checkAndParseVertexId(source);
Id targetId = VertexAPI.checkAndParseVertexId(target);
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
HugeGraph g = graph(manager, graph);
PathsTraverser traverser = new PathsTraverser(g);
HugeTraverser.PathSet paths = traverser.paths(sourceId, dir, targetId, dir.opposite(), edgeLabel, depth, maxDegree, capacity, limit);
return manager.serializer(g).writePaths("paths", paths, false);
}
use of com.baidu.hugegraph.traversal.algorithm.PathsTraverser in project incubator-hugegraph by apache.
the class CrosspointsAPI method get.
@GET
@Timed
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String get(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("source") String source, @QueryParam("target") String target, @QueryParam("direction") String direction, @QueryParam("label") String edgeLabel, @QueryParam("max_depth") int depth, @QueryParam("max_degree") @DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree, @QueryParam("capacity") @DefaultValue(DEFAULT_CAPACITY) long capacity, @QueryParam("limit") @DefaultValue(DEFAULT_PATHS_LIMIT) long limit) {
LOG.debug("Graph [{}] get crosspoints with paths from '{}', to '{}' " + "with direction '{}', edge label '{}', max depth '{}', " + "max degree '{}', capacity '{}' and limit '{}'", graph, source, target, direction, edgeLabel, depth, maxDegree, capacity, limit);
Id sourceId = VertexAPI.checkAndParseVertexId(source);
Id targetId = VertexAPI.checkAndParseVertexId(target);
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
HugeGraph g = graph(manager, graph);
PathsTraverser traverser = new PathsTraverser(g);
HugeTraverser.PathSet paths = traverser.paths(sourceId, dir, targetId, dir, edgeLabel, depth, maxDegree, capacity, limit);
return manager.serializer(g).writePaths("crosspoints", paths, true);
}
Aggregations