/**
* Topological sort of dependent nodes in acyclic graphs.
- *
+ *
* @return Sorted {@link List} of {@link Node}s. Order: Nodes with no
* dependencies starting.
* @throws IllegalStateException
private static Set<Node> getDependentNodes(Set<Node> nodes) {
Set<Node> dependentNodes = Sets.newHashSet();
for (Node n : nodes) {
- if (n.getOutEdges().size() == 0) {
+ if (n.getOutEdges().isEmpty()) {
dependentNodes.add(n);
}
}
private final Set<Edge> inEdges;
private final Set<Edge> outEdges;
+ public NodeImpl() {
+ inEdges = Sets.newHashSet();
+ outEdges = Sets.newHashSet();
+ }
+
@Override
public Set<Edge> getInEdges() {
return inEdges;
outEdges.add(e);
to.getInEdges().add(e);
}
-
- public NodeImpl() {
- inEdges = Sets.newHashSet();
- outEdges = Sets.newHashSet();
- }
}
/**
private final Node from;
private final Node to;
+ public EdgeImpl(Node from, Node to) {
+ this.from = from;
+ this.to = to;
+ }
+
@Override
public Node getFrom() {
return from;
return to;
}
- public EdgeImpl(Node from, Node to) {
- this.from = from;
- this.to = to;
-
- }
-
@Override
public int hashCode() {
final int prime = 31;