com.almondtools.util.graph.PreOrderTraversal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rexlex Show documentation
Show all versions of rexlex Show documentation
Regular expression matchers, searcher, lexers based on deterministic finite automata
package com.almondtools.util.graph;
import java.util.HashSet;
import java.util.Set;
public abstract class PreOrderTraversal extends AbstractTraversal implements Traversal {
private Set> visited;
public PreOrderTraversal(Graph graph) {
super(graph);
this.visited = new HashSet>();
}
@Override
public void traverse() {
super.traverse();
}
@Override
public void traverseNode(GraphNode node) {
if (!visited.contains(node)) {
visited.add(node);
visitGraphNode(node);
for (GraphNode next : node.getSuccessors()) {
next.apply(this);
}
}
}
public abstract void visitGraphNode(GraphNode node);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy