use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.
the class OverlayGraph method removeEdge.
public void removeEdge(Edge e) {
Vertex fromv = e.getFromVertex();
Vertex tov = e.getToVertex();
removeOutgoing(fromv, e);
removeIncoming(tov, e);
}
use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.
the class InterleavedBidirectionalHeuristic method doSomeWork.
/**
* Move backward N steps through the transit network.
* This improves the heuristic's knowledge of the transit network as seen from the target,
* making its lower bounds on path weight progressively more accurate.
*/
@Override
public void doSomeWork() {
if (finished)
return;
for (int i = 0; i < HEURISTIC_STEPS_PER_MAIN_STEP; ++i) {
if (transitQueue.empty()) {
finished = true;
break;
}
int uWeight = (int) transitQueue.peek_min_key();
Vertex u = transitQueue.extract_min();
// The weight of the queue head is uniformly increasing.
// This is the highest weight ever seen for a closed vertex.
maxWeightSeen = uWeight;
// Now that this vertex is closed, we can store its weight for use as a lower bound / heuristic value.
// We don't implement decrease-key operations though, so check whether a smaller value is already known.
double uWeightOld = postBoardingWeights.get(u);
if (uWeight < uWeightOld) {
// Including when uWeightOld is infinite because the vertex is not yet closed.
postBoardingWeights.put(u, uWeight);
} else {
// The vertex was already closed. This time it necessarily has a higher weight, so skip it.
continue;
}
// When the main search is arriveBy the heuristic search looks at OUTgoing edges.
for (Edge e : routingRequest.arriveBy ? u.getOutgoing() : u.getIncoming()) {
// Do not enter streets in this phase, which should only touch transit.
if (e instanceof StreetTransitLink) {
continue;
}
Vertex v = routingRequest.arriveBy ? e.getToVertex() : e.getFromVertex();
double edgeWeight = e.weightLowerBound(routingRequest);
// this saves time by not reverse-exploring those routes and avoids maxFound of INF.
if (Double.isInfinite(edgeWeight)) {
continue;
}
double vWeight = uWeight + edgeWeight;
double vWeightOld = postBoardingWeights.get(v);
if (vWeight < vWeightOld) {
// Should only happen when vWeightOld is infinite because it is not yet closed.
transitQueue.insert(v, vWeight);
}
}
}
}
use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.
the class LinkingTest method jaggedArrayToVertexMap.
private TObjectIntMap<String> jaggedArrayToVertexMap(int[] value, Graph g) {
TObjectIntMap<String> ret = new TObjectIntHashMap<String>();
for (int i = 0; i < value.length; i++) {
Vertex v = g.getVertexById(value[i++]);
if (!v.getLabel().startsWith("osm:node"))
continue;
ret.put(v.getLabel(), value[i]);
}
return ret;
}
use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.
the class GraphVisualizer method traceOld.
protected void traceOld() {
HashSet<Vertex> seenVertices = new HashSet<Vertex>();
DisplayVertex selected = (DisplayVertex) nearbyVertices.getSelectedValue();
if (selected == null) {
System.out.println("no vertex selected");
return;
}
Vertex v = selected.vertex;
System.out.println("initial vertex: " + v);
Queue<Vertex> toExplore = new LinkedList<Vertex>();
toExplore.add(v);
seenVertices.add(v);
while (!toExplore.isEmpty()) {
Vertex src = toExplore.poll();
for (Edge e : src.getOutgoing()) {
Vertex tov = e.getToVertex();
if (!seenVertices.contains(tov)) {
seenVertices.add(tov);
toExplore.add(tov);
}
}
}
showGraph.setHighlightedVertices(seenVertices);
}
use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.
the class GraphVisualizer method trace.
protected void trace() {
DisplayVertex selected = (DisplayVertex) nearbyVertices.getSelectedValue();
if (selected == null) {
return;
}
Vertex v = selected.vertex;
if (tracingVertex != v) {
tracingVertex = v;
closed = new HashSet<Vertex>();
open = new HashSet<Vertex>();
open.add(v);
seen = new HashSet<Vertex>();
}
HashSet<Vertex> newOpen = new HashSet<Vertex>();
for (Vertex v2 : open) {
closed.add(v2);
for (Edge e : v2.getOutgoing()) {
Vertex target = e.getToVertex();
if (closed.contains(target)) {
continue;
}
newOpen.add(target);
}
}
seen.addAll(newOpen);
open = newOpen;
showGraph.setHighlightedVertices(seen);
}
Aggregations