diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetection.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetection.java index 956b06cc3..1ef92bac2 100644 --- a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetection.java +++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetection.java @@ -83,7 +83,7 @@ public void compute(ComputationContext context, Vertex vertex, if (isMin) { sequence.add(id); IdListList sequences = vertex.value(); - sequences.add(sequence); + sequences.add(sequence.copy()); } } else { boolean contains = false; diff --git a/computer-test/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetectionTest.java b/computer-test/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetectionTest.java index 814223201..822a4ec35 100644 --- a/computer-test/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetectionTest.java +++ b/computer-test/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetectionTest.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import org.apache.hugegraph.computer.algorithm.AlgorithmTestBase; import org.apache.hugegraph.computer.core.config.ComputerOptions; @@ -124,6 +125,10 @@ private void assertResult(Id id, List rings) { Set expect = EXPECT_RINGS.getOrDefault(id.toString(), new HashSet<>()); + rings = rings.stream() + .distinct() + .collect(Collectors.toList()); + Assert.assertEquals(expect.size(), rings.size()); for (String ring : rings) { String error = "Expect: '" + ring + "' in " + expect;