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);
}
Aggregations