use of edu.princeton.cs.algs4.In in project AlgorithmsSolutions by Allenskoo856.
the class DepthFirstPaths method main.
public static void main(String[] args) {
Graph G = new Graph(new In(args[0]));
int s = Integer.parseInt(args[1]);
DepthFirstPaths search = new DepthFirstPaths(G, s);
for (int v = 0; v < G.V(); v++) {
StdOut.print(s + " to " + v + ": ");
if (search.hasPathTo(v)) {
for (int x : search.pathTo(v)) {
if (x == s) {
StdOut.print(x);
} else {
StdOut.print("-" + x);
}
}
}
StdOut.println();
}
}
use of edu.princeton.cs.algs4.In in project AlgorithmsSolutions by Allenskoo856.
the class AcyclicSP method main.
public static void main(String[] args) {
EdgeWeightedDigraph G = new EdgeWeightedDigraph(new In(args[0]));
int s = Integer.parseInt(args[1]);
AcyclicSP sp = new AcyclicSP(G, s);
for (int t = 0; t < G.V(); t++) {
StdOut.print(s + " to " + t);
StdOut.printf(" (%4.2f): ", sp.distTo(t));
if (sp.hasPathTo(t)) {
for (DirectedEdge e : sp.pathTo(t)) {
StdOut.print(e + " ");
}
}
StdOut.println();
}
}
use of edu.princeton.cs.algs4.In in project AlgorithmsSolutions by Allenskoo856.
the class Euler method main.
public static void main(String[] args) {
Digraph G = new Digraph(new In(args[0]));
Euler euler = new Euler(G);
if (euler.hasCycle()) {
for (int v : euler.cycle()) {
System.out.print(v + " ");
}
System.out.println();
} else {
System.out.println("Not has Eular cycle");
}
}
use of edu.princeton.cs.algs4.In in project AlgorithmsSolutions by Allenskoo856.
the class BoruvkaMST method main.
public static void main(String[] args) {
In in = new In(args[0]);
EdgeWeightedGraph G = new EdgeWeightedGraph(in);
BoruvkaMST mst = new BoruvkaMST(G);
for (Edge e : mst.edges()) {
StdOut.println(e);
}
StdOut.println(mst.weight());
}
use of edu.princeton.cs.algs4.In in project AlgorithmsSolutions by Allenskoo856.
the class WhiteFilter method main.
public static void main(String[] args) {
SET<String> set = new SET<String>();
In in = new In(args[0]);
while (!in.isEmpty()) {
set.add(in.readString());
}
while (!StdIn.isEmpty()) {
String word = StdIn.readString();
if (set.contains(word)) {
StdOut.print(word + " ");
}
}
}
Aggregations