/** Creates an iterable over the vertices in the given graph in a depth-first * iteration order. */ public static <V, E extends DefaultEdge> Iterable<V> of( DirectedGraph<V, E> graph, V start) { // Doesn't actually return a DepthFirstIterator, but a list with the same // contents, which is more efficient. return buildList(graph, start); }
private Graphs.FrozenGraph<Convention, DefaultEdge> getPathMap() { if (pathMap == null) { pathMap = Graphs.makeImmutable(conversionGraph); } return pathMap; }
private <V> List<V> shortestPath(DirectedGraph<V, DefaultEdge> g, V source, V target) { return Graphs.makeImmutable(g).getShortestPath(source, target); }
private <V> List<List<V>> paths(DirectedGraph<V, DefaultEdge> g, V source, V target) { return Graphs.makeImmutable(g).getPaths(source, target); }
public static <V, E extends DefaultEdge> List<V> predecessorListOf( DirectedGraph<V, E> graph, V vertex) { final List<E> edges = graph.getInwardEdges(vertex); return new AbstractList<V>() { public V get(int index) { //noinspection unchecked return (V) edges.get(index).source; } public int size() { return edges.size(); } }; }
public Set<V> findCycles() { return new TopologicalOrderIterator<>(graph).findCycles(); } }
public TopologicalOrderIterator(DirectedGraph<V, E> graph) { this.graph = (DefaultDirectedGraph<V, E>) graph; populate(countMap, empties); }
public static <V, E extends DefaultEdge> Iterable<V> of( final DirectedGraph<V, E> graph) { return () -> new TopologicalOrderIterator<>(graph); }
public static <V, E extends DefaultEdge> DefaultDirectedGraph<V, E> create( EdgeFactory<V, E> edgeFactory) { return new DefaultDirectedGraph<>(edgeFactory); }
public static <V, E extends DefaultEdge> AttributedDirectedGraph<V, E> create( AttributedEdgeFactory<V, E> edgeFactory) { return new AttributedDirectedGraph<>(edgeFactory); }
private <V> List<V> shortestPath(DirectedGraph<V, DefaultEdge> g, V source, V target) { return Graphs.makeImmutable(g).getShortestPath(source, target); }
private <V> List<List<V>> paths(DirectedGraph<V, DefaultEdge> g, V source, V target) { return Graphs.makeImmutable(g).getPaths(source, target); }
private Graphs.FrozenGraph<Convention, DefaultEdge> getPathMap() { if (pathMap == null) { pathMap = Graphs.makeImmutable(conversionGraph); } return pathMap; }
public static <V, E extends DefaultEdge> List<V> predecessorListOf( DirectedGraph<V, E> graph, V vertex) { final List<E> edges = graph.getInwardEdges(vertex); return new AbstractList<V>() { public V get(int index) { //noinspection unchecked return (V) edges.get(index).source; } public int size() { return edges.size(); } }; }
public Set<V> findCycles() { return new TopologicalOrderIterator<>(graph).findCycles(); } }
/** Creates an iterable over the vertices in the given graph in a depth-first * iteration order. */ public static <V, E extends DefaultEdge> Iterable<V> of( DirectedGraph<V, E> graph, V start) { // Doesn't actually return a DepthFirstIterator, but a list with the same // contents, which is more efficient. return buildList(graph, start); }
public TopologicalOrderIterator(DirectedGraph<V, E> graph) { this.graph = (DefaultDirectedGraph<V, E>) graph; populate(countMap, empties); }
public static <V, E extends DefaultEdge> Iterable<V> of( final DirectedGraph<V, E> graph) { return () -> new TopologicalOrderIterator<>(graph); }