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; }
public DirectedGraph<T> findCycleSubgraph(DirectedGraph<T> graph) { DirectedGraph<T> subGraph = new DirectedGraphImpl<>(); for (Edge<T> edge : graph.getEdges()) { if (isPath(graph, edge.getSink(), edge.getSource())) { subGraph.add(edge); } } return subGraph; }
public DirectedGraph<T> findCycleSubgraph(DirectedGraph<T> graph) { DirectedGraph<T> subGraph = new DirectedGraphImpl<>(); for (Edge<T> edge : graph.getEdges()) { if (isPath(graph, edge.getSink(), edge.getSource())) { subGraph.add(edge); } } return subGraph; }
public DirectedGraph<T> findCycleSubgraph(DirectedGraph<T> graph) { DirectedGraph<T> subGraph = new DirectedGraphImpl<T>(); for (Edge<T> edge : graph.getEdges()) { if (isPath(graph, edge.getSink(), edge.getSource())) { subGraph.add(edge); } } return subGraph; }