public void compute()

in computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetection.java [66:113]


    public void compute(ComputationContext context, Vertex vertex,
                        Iterator<IdList> messages) {
        Id id = vertex.id();
        boolean halt = true;
        while (messages.hasNext()) {
            halt = false;
            IdList sequence = messages.next();
            if (id.equals(sequence.get(0))) {
                // Use the smallest vertex record ring
                boolean isMin = true;
                for (int i = 1; i < sequence.size(); i++) {
                    Id pathVertexValue = sequence.get(i);
                    if (id.compareTo(pathVertexValue) > 0) {
                        isMin = false;
                        break;
                    }
                }
                if (isMin) {
                    sequence.add(id);
                    IdListList sequences = vertex.value();
                    sequences.add(sequence);
                }
            } else {
                boolean contains = false;
                // Drop sequence if path contains this vertex
                for (int i = 0; i < sequence.size(); i++) {
                    Id pathVertexValue = sequence.get(i);
                    if (pathVertexValue.equals(vertex.id())) {
                        contains = true;
                        break;
                    }
                }
                // Field ringId is smallest vertex id in path
                Id ringId = sequence.get(0);
                if (!contains) {
                    sequence.add(vertex.id());
                    for (Edge edge : vertex.edges()) {
                        if (ringId.compareTo(edge.targetId()) <= 0) {
                            context.sendMessage(edge.targetId(), sequence);
                        }
                    }
                }
            }
        }
        if (halt) {
            vertex.inactivate();
        }
    }