• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / IntegratedDynamics / 13601780000

01 Mar 2025 05:59AM UTC coverage: 39.002% (+0.002%) from 39.0%
13601780000

push

github

rubensworks
Improve performance of block changes to very large networks

Pathfinder is ~70x faster, also improved tick speed with lots of devices (17 ms to 3 ms in test scene)

1948 of 8349 branches covered (23.33%)

Branch coverage included in aggregate %.

10283 of 23011 relevant lines covered (44.69%)

2.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.0
/src/main/java/org/cyclops/integrateddynamics/core/path/PathFinder.java
1
package org.cyclops.integrateddynamics.core.path;
2

3
import org.cyclops.cyclopscore.datastructure.DimPos;
4
import org.cyclops.integrateddynamics.api.path.IPathElement;
5
import org.cyclops.integrateddynamics.api.path.ISidedPathElement;
6

7
import java.util.ArrayDeque;
8
import java.util.HashSet;
9
import java.util.Queue;
10
import java.util.Set;
11
import java.util.TreeSet;
12

13

14
/**
15
 * Algorithm to construct paths/clusters of {@link IPathElement}s.
16
 * @author rubensworks
17
 */
18
public final class PathFinder {
×
19

20
    protected static Set<ISidedPathElement> getConnectedElements(ISidedPathElement head) {
21
        Set<ISidedPathElement> connectedElements = new HashSet<>();
4✔
22
        Set<DimPos> visitedPositions = new HashSet<>();
4✔
23

24
        // Use a queue for BFS traversal.
25
        Queue<ISidedPathElement> queue = new ArrayDeque<>();
4✔
26
        DimPos headPos = head.getPathElement().getPosition();
4✔
27
        visitedPositions.add(headPos);
4✔
28
        queue.offer(head);
4✔
29

30
        while (!queue.isEmpty()) {
3✔
31
            ISidedPathElement current = queue.poll();
4✔
32
            connectedElements.add(current);
4✔
33
            IPathElement currentElement = current.getPathElement();
3✔
34

35
            for (ISidedPathElement neighbour : currentElement.getReachableElements()) {
11✔
36
                DimPos neighbourPos = neighbour.getPathElement().getPosition();
4✔
37
                if (visitedPositions.add(neighbourPos)) { // Adds and returns true if not already present.
4✔
38
                    queue.offer(neighbour);
4✔
39
                }
40
            }
1✔
41
        }
1✔
42

43
        return connectedElements;
2✔
44
    }
45

46
    public static Cluster getConnectedCluster(ISidedPathElement head) {
47
        return new Cluster(new TreeSet<>(getConnectedElements(head)));
9✔
48
    }
49
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc