package graph; import java.util.List; /** Assorted graph algorithms. * @author */ public final class Graphs { /* A* Search Algorithms */ /** Returns a path from V0 to V1 in G of minimum weight, according * to the edge weighter EWEIGHTER. VLABEL and ELABEL are the types of * vertex and edge labels. Assumes that H is a distance measure * between vertices satisfying the two properties: * a. H.dist(v, V1) <= shortest path from v to V1 for any v, and * b. H.dist(v, w) <= H.dist(w, V1) + weight of edge (v, w), where * v and w are any vertices in G. * * As a side effect, uses VWEIGHTER to set the weight of vertex v * to the weight of a minimal path from V0 to v, for each v in * the returned path and for each v such that * minimum path length from V0 to v + H.dist(v, V1) * < minimum path length from V0 to V1. * The final weights of other vertices are not defined. If V1 is * unreachable from V0, returns null and sets the minimum path weights of * all reachable nodes. The distance to a node unreachable from V0 is * Double.POSITIVE_INFINITY. */ public static List.Edge> shortestPath(Graph G, Graph.Vertex V0, Graph.Vertex V1, Distancer h, Weighter vweighter, Weighting eweighter) { return null; // FIX ME } /** Returns a path from V0 to V1 in G of minimum weight, according * to the weights of its edge labels. VLABEL and ELABEL are the types of * vertex and edge labels. Assumes that H is a distance measure * between vertices satisfying the two properties: * a. H.dist(v, V1) <= shortest path from v to V1 for any v, and * b. H.dist(v, w) <= H.dist(w, V1) + weight of edge (v, w), where * v and w are any vertices in G. * * As a side effect, sets the weight of vertex v to the weight of * a minimal path from V0 to v, for each v in the returned path * and for each v such that * minimum path length from V0 to v + H.dist(v, V1) * < minimum path length from V0 to V1. * The final weights of other vertices are not defined. * * This function has the same effect as the 6-argument version of * shortestPath, but uses the .weight and .setWeight methods of * the edges and vertices themselves to determine and set * weights. If V1 is unreachable from V0, returns null and sets * the minimum path weights of all reachable nodes. The distance * to a node unreachable from V0 is Double.POSITIVE_INFINITY. */ public static List.Edge> shortestPath(Graph G, Graph.Vertex V0, Graph.Vertex V1, Distancer h) { return null; // FIX ME } /** Returns a distancer whose dist method always returns 0. */ public static final Distancer ZERO_DISTANCER = new Distancer() { @Override public double dist(Object v0, Object v1) { return 0.0; } }; }