Skip to content

Instantly share code, notes, and snippets.

@kietdlam
Created December 11, 2013 06:40
Show Gist options
  • Save kietdlam/7905982 to your computer and use it in GitHub Desktop.
Save kietdlam/7905982 to your computer and use it in GitHub Desktop.
package trip;
/* You MAY add public @Test methods to this class. You may also add
* additional public classes containing "Testing" in their name. These
* may not be part of your trip package per se (that is, it must be
* possible to remove them and still have your package work). */
import org.junit.Test;
import ucb.junit.textui;
import static org.junit.Assert.*;
import graph.Graph;
import graph.Graphs;
import graph.UndirectedGraph;
import graph.Distancer;
import graph.Weighting;
import graph.Weighter;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
/** Unit tests for the trip package. */
public class Testing {
/** Run all JUnit tests in the graph package. */
public static void main(String[] ignored) {
System.exit(textui.runClasses(trip.Testing.class));
}
@Test
public void testMe() {
}
@Test
public void testAStar() {
Graph<String, String> g = new UndirectedGraph<String, String>();
Graph<String, String>.Vertex A = g.add("A");
Graph<String, String>.Vertex B = g.add("B");
g.add(A, B, "A-B");
Distancer<String> distancer = new Distancer<String>() {
@Override
public double dist(String v0, String v1) {
return 0.0;
}
};
Weighting<String> eweighter = new Weighting<String>() {
@Override
public double weight(String str) {
return 1.0;
}
};
Weighter<String> vweighter = new Weighter<String>() {
@Override
public void setWeight(String str, double v) {
}
@Override
public double weight(String str) {
return 1.0;
}
};
List<Graph<String, String>.Edge> output
= Graphs.shortestPath(g, A, B, distancer, vweighter, eweighter);
assertNotNull("Why does this always fail???", output);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment