/** * Computes a path from a location to the nearest source. Contains both start and end points. * * @param loc The location. * @return The path as a LocSet. */ public LocSet getPath(MapLocation loc) { LocSet path = new LocSet(); path.insert(loc); while (!sources.contains(loc)) { loc = loc.subtract(from[loc.x][loc.y]); path.insert(loc); } return path; }