Search in sources :

Example 1 with SameNeighborTraverser

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

the class SameNeighborsAPI method get.

@GET
@Timed
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String get(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("vertex") String vertex, @QueryParam("other") String other, @QueryParam("direction") String direction, @QueryParam("label") String edgeLabel, @QueryParam("max_degree") @DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree, @QueryParam("limit") @DefaultValue(DEFAULT_ELEMENTS_LIMIT) long limit) {
    LOG.debug("Graph [{}] get same neighbors between '{}' and '{}' with " + "direction {}, edge label {}, max degree '{}' and limit '{}'", graph, vertex, other, direction, edgeLabel, maxDegree, limit);
    Id sourceId = VertexAPI.checkAndParseVertexId(vertex);
    Id targetId = VertexAPI.checkAndParseVertexId(other);
    Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
    HugeGraph g = graph(manager, graph);
    SameNeighborTraverser traverser = new SameNeighborTraverser(g);
    Set<Id> neighbors = traverser.sameNeighbors(sourceId, targetId, dir, edgeLabel, maxDegree, limit);
    return manager.serializer(g).writeList("same_neighbors", neighbors);
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) SameNeighborTraverser(com.baidu.hugegraph.traversal.algorithm.SameNeighborTraverser) Directions(com.baidu.hugegraph.type.define.Directions) 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)1 Id (com.baidu.hugegraph.backend.id.Id)1 SameNeighborTraverser (com.baidu.hugegraph.traversal.algorithm.SameNeighborTraverser)1 Directions (com.baidu.hugegraph.type.define.Directions)1 Timed (com.codahale.metrics.annotation.Timed)1 GET (jakarta.ws.rs.GET)1 Produces (jakarta.ws.rs.Produces)1