public List<Cycle<T>> findCycles(DirectedGraph<T> graph) { List<Cycle<T>> cycles = new ArrayList<>(); for (Edge<T> edge : graph.getEdges()) { List<Vertex<T>> path = getPath(graph, edge.getSink(), edge.getSource()); if (!path.isEmpty()) { Cycle<T> cycle = searchCycle(cycles, edge); if (cycle == null) { cycle = new Cycle<>(); cycle.setOriginPath(path); cycles.add(cycle); } else { cycle.setBackPath(path); } } } return cycles; }
public List<Cycle<T>> findCycles(DirectedGraph<T> graph) { List<Cycle<T>> cycles = new ArrayList<>(); for (Edge<T> edge : graph.getEdges()) { List<Vertex<T>> path = getPath(graph, edge.getSink(), edge.getSource()); if (!path.isEmpty()) { Cycle<T> cycle = searchCycle(cycles, edge); if (cycle == null) { cycle = new Cycle<>(); cycle.setOriginPath(path); cycles.add(cycle); } else { cycle.setBackPath(path); } } } return cycles; }
public List<Cycle<T>> findCycles(DirectedGraph<T> graph) { List<Cycle<T>> cycles = new ArrayList<Cycle<T>>(); for (Edge<T> edge : graph.getEdges()) { List<Vertex<T>> path = getPath(graph, edge.getSink(), edge.getSource()); if (!path.isEmpty()) { Cycle<T> cycle = searchCycle(cycles, edge); if (cycle == null) { cycle = new Cycle<T>(); cycle.setOriginPath(path); cycles.add(cycle); } else { cycle.setBackPath(path); } } } return cycles; }