double w = 0;
if (isFromSourceStop) {
if (parentNode != null) {
StopEntry fromStop = parentNode.getToStop();
StopEntry toStop = node.getFromStop();
double transferWeight = computeTransferWeight(
fromStop.getStopLocation(), toStop.getStopLocation());
w += transferWeight;
}
StopEntry fromStop = node.getFromStop();
StopEntry toStop = node.getToStop();
int transitWeight = computeTransitWeight(fromStop.getStopLocation(),
toStop.getStopLocation());
w += transitWeight;
}
/**
* What's our best option?
*/
double minOption = node.getMinRemainingWeight();
if (minOption < 0) {
minOption = Double.POSITIVE_INFINITY;
/**
* We could exit if we're allowed, walking to our destination
*/
if (node.isExitAllowed()) {
StopEntry toStop = node.getToStop();
double transferWeight = computeTransferWeight(toStop.getStopLocation(),
target);
minOption = Math.min(transferWeight, minOption);
}
/**
* Or we could transfer to another transfer pattern
*/
Collection<TransferNode> transfers = node.getTransfers();
for (TransferNode subTree : transfers) {
if (!visitedNodes.contains(subTree)) {
double subWeight = getWeightForTransferNode(node, subTree, true,
target, visitedNodes);
minOption = Math.min(subWeight, minOption);
}
}
Collection<HubNode> hubs = node.getHubs();
for (HubNode hubNode : hubs) {
StopEntry hubStop = hubNode.getHubStop();
CoordinatePoint hubLocation = hubStop.getStopLocation();
double transferWeight = computeTransferWeight(
node.getToStop().getStopLocation(), hubLocation);
double transitWeight = computeTransitWeight(hubLocation, target);
double subWeight = transferWeight + transitWeight;
minOption = Math.min(subWeight, minOption);