use of im.tny.segvault.s2ls.routing.LeastHopsWeighter in project underlx by underlx.
the class Path method manualExtendStart.
public void manualExtendStart(Stop vertex) {
// start by reverting to the path with the start without user-made extensions
int edgesToRemove = 0;
while (manualEntry.get(0)) {
manualEntry.remove(0);
times.remove(0);
edgesToRemove++;
}
for (int i = 0; i < edgesToRemove; i++) {
edgeList.remove(0);
}
if (edgeList.size() > 0) {
startVertex = edgeList.get(0).getSource();
}
// now go from the program-made start
Date time = times.get(0).first;
List<Connection> cs = Route.getShortestPath(graph, vertex, startVertex, new LeastHopsWeighter()).getEdgeList();
int size = cs.size();
int insertPos = 0;
for (int i = 0; i < size; i++) {
// never add a transfer as the first step
if (i == 0 && cs.get(i) instanceof Transfer) {
continue;
}
times.add(insertPos, new Pair<Date, Date>(time, time));
manualEntry.add(insertPos, true);
edgeList.add(insertPos++, cs.get(i));
}
this.startVertex = vertex;
for (OnPathChangedListener l : listeners) {
l.onPathChanged(this);
}
}
use of im.tny.segvault.s2ls.routing.LeastHopsWeighter in project underlx by underlx.
the class Path method manualExtendEnd.
public void manualExtendEnd(Stop vertex) {
// start by reverting to the path with the end without user-made extensions
int edgesToRemove = 0;
while (manualEntry.get(manualEntry.size() - 1)) {
manualEntry.remove(manualEntry.size() - 1);
times.remove(times.size() - 1);
edgesToRemove++;
}
for (int i = 0; i < edgesToRemove; i++) {
edgeList.remove(edgeList.size() - 1);
}
if (edgeList.size() > 0) {
endVertex = edgeList.get(edgeList.size() - 1).getTarget();
}
// now go from the program-made end
Date time = times.get(times.size() - 1).second;
List<Connection> cs = Route.getShortestPath(graph, endVertex, vertex, new LeastHopsWeighter()).getEdgeList();
int size = cs.size();
for (int i = 0; i < size; i++) {
// the same line)
if (i == size - 1 && cs.get(i) instanceof Transfer) {
this.endVertex = cs.get(i).getSource();
return;
}
times.add(new Pair<Date, Date>(time, time));
manualEntry.add(true);
edgeList.add(cs.get(i));
}
this.endVertex = vertex;
for (OnPathChangedListener l : listeners) {
l.onPathChanged(this);
}
}
Aggregations