class Traverser extends AlgoTraverser {

        public Traverser(UserJob<Object> job, int workers) {
            super(job, ALGO_NAME, workers);
        }

        public Object rings(String sourceLabel, String sourceCLabel,
                            Directions dir, String label, int depth,
                            long degree, long eachLimit, long limit,
                            boolean countOnly) {<FILL_FUNCTION_BODY>}
    }

            JsonMap ringsJson = new JsonMap();
            ringsJson.startObject();
            if (countOnly) {
                ringsJson.appendKey("rings_count");
            } else {
                ringsJson.appendKey("rings");
                ringsJson.startList();
            }

            SubGraphTraverser traverser = new SubGraphTraverser(this.graph());
            AtomicLong count = new AtomicLong(0L);

            this.traverse(sourceLabel, sourceCLabel, v -> {
                Id source = (Id) v.id();
                PathSet rings = traverser.rings(source, dir, label, depth,
                                                true, degree, MAX_CAPACITY,
                                                eachLimit);
                assert eachLimit == NO_LIMIT || rings.size() <= eachLimit;
                for (Path ring : rings) {
                    if (eachLimit == NO_LIMIT && !ring.ownedBy(source)) {
                        // Only dedup rings when each_limit!=NO_LIMIT
                        continue;
                    }

                    if (count.incrementAndGet() > limit && limit != NO_LIMIT) {
                        throw new StopExecution("exceed limit %s", limit);
                    }
                    if (!countOnly) {
                        String ringJson = JsonUtil.toJson(ring.vertices());
                        synchronized (ringsJson) {
                            ringsJson.appendRaw(ringJson);
                        }
                    }
                }
            });

            if (countOnly) {
                long counted = count.get();
                if (limit != NO_LIMIT && counted > limit) {
                    // The count increased by multi threads and exceed limit
                    counted = limit;
                }
                ringsJson.append(counted);
            } else {
                ringsJson.endList();
            }
            ringsJson.endObject();

            return ringsJson.asJson();
        
<methods>public non-sealed void <init>() ,public void checkParameters(Map<java.lang.String,java.lang.Object>) <variables>public static final int BATCH,public static final java.lang.String CATEGORY_AGGR,public static final java.lang.String CATEGORY_CENT,public static final java.lang.String CATEGORY_COMM,public static final java.lang.String CATEGORY_PATH,public static final java.lang.String CATEGORY_RANK,public static final java.lang.String CATEGORY_SIMI,public static final java.lang.String C_LABEL,public static final double DEFAULT_ALPHA,public static final long DEFAULT_CAPACITY,public static final long DEFAULT_DEGREE,public static final long DEFAULT_EACH_LIMIT,public static final long DEFAULT_LIMIT,public static final double DEFAULT_PRECISION,public static final long DEFAULT_SAMPLE,public static final long DEFAULT_STABLE_TIMES,public static final long DEFAULT_TIMES,public static final java.lang.String EXPORT_PATH,public static final java.lang.String KEY_ALPHA,public static final java.lang.String KEY_CAPACITY,public static final java.lang.String KEY_CLEAR,public static final java.lang.String KEY_DEGREE,public static final java.lang.String KEY_DEPTH,public static final java.lang.String KEY_DIRECTION,public static final java.lang.String KEY_EACH_LIMIT,public static final java.lang.String KEY_EXPORT_COMM,public static final java.lang.String KEY_LABEL,public static final java.lang.String KEY_LIMIT,public static final java.lang.String KEY_PRECISION,public static final java.lang.String KEY_SAMPLE,public static final java.lang.String KEY_SHOW_COMM,public static final java.lang.String KEY_SHOW_MOD,public static final java.lang.String KEY_SKIP_ISOLATED,public static final java.lang.String KEY_SOURCE_CLABEL,public static final java.lang.String KEY_SOURCE_LABEL,public static final java.lang.String KEY_SOURCE_SAMPLE,public static final java.lang.String KEY_STABLE_TIMES,public static final java.lang.String KEY_TIMES,public static final java.lang.String KEY_TOP,public static final java.lang.String KEY_WORKERS,public static final long MAX_CAPACITY,public static final long MAX_QUERY_LIMIT,public static final long MAX_RESULT_SIZE,public static final java.lang.String R_RANK,public static final java.lang.String USER_DIR