Skip to content

Commit 85e6399

Browse files
corgiboygsj枫川
andauthored
fix(algorithm): record loop is not copied (#276)
Co-authored-by: 枫川 <guoshoujing.gsj@alibaba-inc.com>
1 parent d55680c commit 85e6399

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void compute(ComputationContext context, Vertex vertex,
8383
if (isMin) {
8484
sequence.add(id);
8585
IdListList sequences = vertex.value();
86-
sequences.add(sequence);
86+
sequences.add(sequence.copy());
8787
}
8888
} else {
8989
boolean contains = false;

computer-test/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetectionTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.List;
2222
import java.util.Map;
2323
import java.util.Set;
24+
import java.util.stream.Collectors;
2425

2526
import org.apache.hugegraph.computer.algorithm.AlgorithmTestBase;
2627
import org.apache.hugegraph.computer.core.config.ComputerOptions;
@@ -124,6 +125,10 @@ private void assertResult(Id id, List<String> rings) {
124125
Set<String> expect = EXPECT_RINGS.getOrDefault(id.toString(),
125126
new HashSet<>());
126127

128+
rings = rings.stream()
129+
.distinct()
130+
.collect(Collectors.toList());
131+
127132
Assert.assertEquals(expect.size(), rings.size());
128133
for (String ring : rings) {
129134
String error = "Expect: '" + ring + "' in " + expect;

0 commit comments

Comments
 (0)