Ver código fonte

improve error message upon finding cycle

tags/2.0.1
Jonathan Cobb 5 anos atrás
pai
commit
7fd01de00a
1 arquivos alterados com 3 adições e 3 exclusões
  1. +3
    -3
      src/main/java/org/cobbzilla/util/collection/Topology.java

+ 3
- 3
src/main/java/org/cobbzilla/util/collection/Topology.java Ver arquivo

@@ -89,8 +89,8 @@ public class Topology<T> {
// remove edge e from the graph
final Edge<T> e = it.next();
final Node<T> m = e.to;
it.remove();//Remove edge from n
m.inEdges.remove(e);//Remove edge from m
it.remove(); // Remove edge from n
m.inEdges.remove(e); // Remove edge from m

// if m has no other incoming edges then insert m into S
if (m.inEdges.isEmpty()) S.add(m);
@@ -99,7 +99,7 @@ public class Topology<T> {
// Check to see if all edges are removed
for (Node<T> n : nodes) {
if (!n.inEdges.isEmpty()) {
return die("Cycle present, topological sort not possible");
return die("Cycle present, topological sort not possible: "+n.thing.toString()+" <- ["+n.inEdges.stream().map(e->e.from.thing.toString()).collect(Collectors.joining(", "))+"]");
}
}
return L.stream().map(n -> n.thing).collect(Collectors.toList());


Carregando…
Cancelar
Salvar