private Cycle<T> searchCycle(List<Cycle<T>> cycles, Edge<T> edge) { for (Cycle<T> cycle : cycles) { List<Vertex<T>> path = cycle.getOriginPath(); Vertex<T> vertex = path.get(0); if (vertex.equals(edge.getSink())) { return cycle; } } return null; }
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; }
private Cycle<T> searchCycle(List<Cycle<T>> cycles, Edge<T> edge) { for (Cycle<T> cycle : cycles) { List<Vertex<T>> path = cycle.getOriginPath(); Vertex<T> vertex = path.get(0); if (vertex.equals(edge.getSink())) { return cycle; } } return null; }
private Cycle<T> searchCycle(List<Cycle<T>> cycles, Edge<T> edge) { for (Cycle<T> cycle : cycles) { List<Vertex<T>> path = cycle.getOriginPath(); Vertex<T> vertex = path.get(0); if (vertex.equals(edge.getSink())) { return cycle; } } return null; }