/** Unit tests the <tt>Topological</tt> data type. */ public static void main(String[] args) { String filename = args[0]; String delimiter = args[1]; SymbolDigraph sg = new SymbolDigraph(filename, delimiter); Topological topological = new Topological(sg.G()); for (int v : topological.order()) { StdOut.println(sg.name(v)); } }
public AcyclicLP(EdgeWeightedDigraph G, int s) { distTo = new double[G.V()]; edgeTo = new DirectedEdge[G.V()]; for (int v = 0; v < G.V(); v++) distTo[v] = Double.NEGATIVE_INFINITY; distTo[s] = 0.0; // relax vertices in toplogical order Topological topological = new Topological(G); for (int v : topological.order()) { for (DirectedEdge e : G.adj(v)) relax(e); } }
public AcyclicSP(EdgeWeightedDigraph G ,int s){ edgeTo = new DirectedEdge[G.V()]; distTo = new double[G.V()]; for(int v = 0 ; v < G.V() ; v++){ distTo[v] = Double.POSITIVE_INFINITY; } distTo[s] = 0.0; Topological top = new Topological(G); for(int v:top.order()){ relax(G,v); } }