Search in sources :

Example 1 with SubGraphTraverser

use of com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser in project incubator-hugegraph by apache.

the class RaysAPI method get.

@GET
@Timed
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String get(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("source") String sourceV, @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 rays paths from '{}' with " + "direction '{}', edge label '{}', max depth '{}', " + "max degree '{}', capacity '{}' and limit '{}'", graph, sourceV, direction, edgeLabel, depth, maxDegree, capacity, limit);
    Id source = VertexAPI.checkAndParseVertexId(sourceV);
    Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
    HugeGraph g = graph(manager, graph);
    SubGraphTraverser traverser = new SubGraphTraverser(g);
    HugeTraverser.PathSet paths = traverser.rays(source, dir, edgeLabel, depth, maxDegree, capacity, limit);
    return manager.serializer(g).writePaths("rays", paths, false);
}
Also used : SubGraphTraverser(com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser) HugeGraph(com.baidu.hugegraph.HugeGraph) Directions(com.baidu.hugegraph.type.define.Directions) HugeTraverser(com.baidu.hugegraph.traversal.algorithm.HugeTraverser) Id(com.baidu.hugegraph.backend.id.Id) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(jakarta.ws.rs.GET)

Example 2 with SubGraphTraverser

use of com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser in project incubator-hugegraph by apache.

the class RingsAPI method get.

@GET
@Timed
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String get(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("source") String sourceV, @QueryParam("direction") String direction, @QueryParam("label") String edgeLabel, @QueryParam("max_depth") int depth, @QueryParam("source_in_ring") @DefaultValue("true") boolean sourceInRing, @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 rings paths reachable from '{}' with " + "direction '{}', edge label '{}', max depth '{}', " + "source in ring '{}', max degree '{}', capacity '{}' " + "and limit '{}'", graph, sourceV, direction, edgeLabel, depth, sourceInRing, maxDegree, capacity, limit);
    Id source = VertexAPI.checkAndParseVertexId(sourceV);
    Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
    HugeGraph g = graph(manager, graph);
    SubGraphTraverser traverser = new SubGraphTraverser(g);
    HugeTraverser.PathSet paths = traverser.rings(source, dir, edgeLabel, depth, sourceInRing, maxDegree, capacity, limit);
    return manager.serializer(g).writePaths("rings", paths, false);
}
Also used : SubGraphTraverser(com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser) HugeGraph(com.baidu.hugegraph.HugeGraph) Directions(com.baidu.hugegraph.type.define.Directions) HugeTraverser(com.baidu.hugegraph.traversal.algorithm.HugeTraverser) Id(com.baidu.hugegraph.backend.id.Id) Produces(jakarta.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(jakarta.ws.rs.GET)

Aggregations

HugeGraph (com.baidu.hugegraph.HugeGraph)2 Id (com.baidu.hugegraph.backend.id.Id)2 HugeTraverser (com.baidu.hugegraph.traversal.algorithm.HugeTraverser)2 SubGraphTraverser (com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser)2 Directions (com.baidu.hugegraph.type.define.Directions)2 Timed (com.codahale.metrics.annotation.Timed)2 GET (jakarta.ws.rs.GET)2 Produces (jakarta.ws.rs.Produces)2