use of edu.princeton.cs.algs4.In in project algorithms-sedgewick-wayne by reneargento.
the class Exercise27_Animations_Prim method main.
public static void main(String[] args) {
// String filePath = Constants.FILES_PATH + Constants.TINY_EWG_FILE;
String filePath = Constants.FILES_PATH + Constants.MEDIUM_EWG_FILE;
EdgeWeightedGraph edgeWeightedGraph = new EdgeWeightedGraph(new In(filePath));
// new Exercise27_Animations_Prim().new PrimMSTAnimations(edgeWeightedGraph, -0.1, 1.1,
// -0.1, 1.1, 0.04); // Use these dimensions for tinyEWG.txt
new Exercise27_Animations_Prim().new PrimMSTAnimations(edgeWeightedGraph, -1, 1001, -1, 1001, 15);
}
use of edu.princeton.cs.algs4.In in project algorithms-sedgewick-wayne by reneargento.
the class DirectedDFS method main.
public static void main(String[] args) {
Digraph digraph = new Digraph(new In(args[0]));
Bag<Integer> sources = new Bag<>();
for (int i = 1; i < args.length; i++) {
sources.add(Integer.parseInt(args[i]));
}
DirectedDFS reachable = new DirectedDFS(digraph, sources);
for (int vertex = 0; vertex < digraph.vertices(); vertex++) {
if (reachable.visited[vertex]) {
StdOut.print(vertex + " ");
}
}
StdOut.println();
}
use of edu.princeton.cs.algs4.In in project algorithms-sedgewick-wayne by reneargento.
the class Exercise2 method main.
/**
* File content:
* 6
* 5
* 2 5 33
* 3 2 14
* 4 5 89
* 4 5 86
* 3 0 15
*/
public static void main(String[] args) {
String filePath = Constants.FILES_PATH + Constants.EWD_FILE;
EdgeWeightedDigraphWithInConstructor edgeWeightedDigraphWithInConstructor = new Exercise2().new EdgeWeightedDigraphWithInConstructor(new In(filePath));
StdOut.println(edgeWeightedDigraphWithInConstructor);
StdOut.println("Expected:\n" + "0: \n" + "1: \n" + "2: 2->5 33.00 \n" + "3: 3->0 15.00 3->2 14.00 \n" + "4: 4->5 86.00 4-5 89.00 \n" + "5: ");
}
use of edu.princeton.cs.algs4.In in project AlgorithmsSolutions by Allenskoo856.
the class AcyclicLP method main.
public static void main(String[] args) {
In in = new In(args[0]);
int s = Integer.parseInt(args[1]);
EdgeWeightedDigraph G = new EdgeWeightedDigraph(in);
AcyclicLP lp = new AcyclicLP(G, s);
for (int v = 0; v < G.V(); v++) {
if (lp.hasPathTo(v)) {
System.out.printf("%d to %d (%.2f) ", s, v, lp.distTo(v));
for (DirectedEdge e : lp.pathTo(v)) {
System.out.print(e + " ");
}
System.out.println();
} else {
System.out.printf("%d to %d no path\n", s, v);
}
}
}
use of edu.princeton.cs.algs4.In in project AlgorithmsSolutions by Allenskoo856.
the class TestSearch method main.
public static void main(String[] args) {
Graph G = new Graph(new In(args[0]));
int s = Integer.parseInt(args[1]);
DepthFirstSearch search = new DepthFirstSearch(G, s);
for (int v = 0; v < G.V(); v++) {
if (search.marked(v)) {
StdOut.print(v + " ");
}
}
StdOut.println();
if (search.count() != G.V()) {
StdOut.print("NOT ");
}
StdOut.println("connected");
}
Aggregations