- /* PRECONDITION: this is the common ancestor of src and dst */
- bool AsImpl::getBypassRoute(routing::NetCard* src, routing::NetCard* dst,
- /* OUT */ std::vector<surf::Link*>* links, double* latency)
- {
- // If never set a bypass route return nullptr without any further computations
- XBT_DEBUG("generic_get_bypassroute from %s to %s", src->name(), dst->name());
- if (bypassRoutes_.empty())
- return false;
-
- /* Base case, no recursion is needed */
- if(dst->containingAS() == this && src->containingAS() == this ){
- if (bypassRoutes_.find({src->name(),dst->name()}) != bypassRoutes_.end()) {
- std::vector<surf::Link*>* bypassedRoute = bypassRoutes_.at({src->name(), dst->name()});
- for (surf::Link* link : *bypassedRoute) {
- links->push_back(link);
- if (latency)
- *latency += link->latency();
- }
- XBT_DEBUG("Found a bypass route with %zu links",bypassedRoute->size());
- return true;
+ /* (4) we found the difference at least. Finalize the returned values */
+ *src_ancestor = path_src.at(path_src.size() - 1); /* the first different father of src */
+ *dst_ancestor = path_dst.at(path_dst.size() - 1); /* the first different father of dst */
+ if (*src_ancestor == *dst_ancestor) { // src is the ancestor of dst, or the contrary
+ *common_ancestor = *src_ancestor;
+ } else {
+ *common_ancestor = father;
+ }
+ }
+
+ /* PRECONDITION: this is the common ancestor of src and dst */
+ bool AsImpl::getBypassRoute(routing::NetCard* src, routing::NetCard* dst,
+ /* OUT */ std::vector<surf::Link*>* links, double* latency)
+ {
+ // If never set a bypass route return nullptr without any further computations
+ if (bypassRoutes_.empty())
+ return false;
+
+ /* Base case, no recursion is needed */
+ if (dst->containingAS() == this && src->containingAS() == this) {
+ if (bypassRoutes_.find({src, dst}) != bypassRoutes_.end()) {
+ AsRoute* bypassedRoute = bypassRoutes_.at({src, dst});
+ for (surf::Link* link : bypassedRoute->links) {
+ links->push_back(link);
+ if (latency)
+ *latency += link->latency();