private boolean isCycle(DirectedGraph<T> graph, Vertex<T> from) { Set<Edge<T>> edges = graph.getOutgoingEdges(from); for (Edge<T> edge : edges) { Vertex<T> opposite = edge.getOppositeVertex(from); if (isPath(graph, opposite, from)) { // cycle found return true; } } return false; }
private boolean isCycle(DirectedGraph<T> graph, Vertex<T> from) { Set<Edge<T>> edges = graph.getOutgoingEdges(from); for (Edge<T> edge : edges) { Vertex<T> opposite = edge.getOppositeVertex(from); if (isPath(graph, opposite, from)) { // cycle found return true; } } return false; }
private boolean isCycle(DirectedGraph<T> graph, Vertex<T> from) { Set<Edge<T>> edges = graph.getOutgoingEdges(from); for (Edge<T> edge : edges) { Vertex<T> opposite = edge.getOppositeVertex(from); if (isPath(graph, opposite, from)) { // cycle found return true; } } return false; }
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; }