Skip to content

Commit

Permalink
Add clarifying comment
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Dupuy <[email protected]>
  • Loading branch information
flo-dup committed Dec 4, 2024
1 parent c610f1f commit 1f0b295
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,20 @@ private void traverse(int n, boolean[] encountered, Predicate<SwitchImpl> termin
if (!encountered[n]) {
final TIntArrayList nodes = new TIntArrayList(1);
nodes.add(n);
graph.traverse(n, TraversalType.DEPTH_FIRST, (n1, e, n2) -> {
Traverser traverser = (n1, e, n2) -> {
SwitchImpl aSwitch = graph.getEdgeObject(e);
if (aSwitch != null && terminate.test(aSwitch)) {
return TraverseResult.TERMINATE_PATH;
}

if (!encountered[n2]) {
// We need to check this as the traverser might be called twice with the same n2 but with different edges.
// Note that the "encountered" array is used and maintained inside graph::traverse method, hence we should not update it.
nodes.add(n2);
}
return TraverseResult.CONTINUE;
}, encountered);
};
graph.traverse(n, TraversalType.DEPTH_FIRST, traverser, encountered);

// check that the component is a bus
String busId = Identifiables.getUniqueId(NAMING_STRATEGY.getId(voltageLevel, nodes), getNetwork().getIndex()::contains);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,11 @@ public interface UndirectedGraph<V, E> {
* @param v the vertex index where the traverse has to start.
* @param traversalType the type of traversal (breadth-first or depth-first)
* @param traverser the {@link Traverser} instance to use to know if the traverse should continue or stop.
* @param verticesEncountered the list of traversed vertices.
* @param verticesEncountered the list of traversed vertices - a vertex is considered as traversed:
* <ul>
* <li>if it is the starting vertex</li>
* <li>if one of its edges has been traversed, with a traverser result {@link TraverseResult#CONTINUE}</li>
* </ul>
* @return false if the whole traversing has to stop, meaning that a {@link TraverseResult#TERMINATE_TRAVERSER}
* has been returned from the traverser, true otherwise
*/
Expand Down

0 comments on commit 1f0b295

Please sign in to comment.