// traverse the ring and add the shortcut links to it. *operation* void build_shortcuts() *traverse* *from* Ring *through* -> *, source, * *to-stop* VNode *carry* *in* Ring* ring = (@ this @) *along* *from* Ring *through* -> *, source, * *to-stop* VNode *carry* *in* VirtualAdjacency* adj *along* *from* VirtualAdjacency *through* -> *, source, * *to-stop* VNode *at* VirtualAdjacency adj = (@ this @) *wrapper* VNode (@ VNode_ParList* shortcut_vnodes = get_phys_node()->all_vnodes_but(this); VNode_ParList* jump_vnodes = adj->get_jump_vnodes(); ring->connect_shortcuts(shortcut_vnodes, jump_vnodes, ring->get_nextdefault(adj)->get_source()); @) // add to the ring shortcuts from the vnodes in "vnodelist1" to the // the nodes in "vnodelist2" and to "next_vnode". *operation* void connect_shortcuts(VNode_ParList* vnodelist1, VNode_ParList* vnodelist2, VNode* next_vnode) *wrapper* Ring (@ VNode_list_iterator next_vnode1(*vnodelist1); VNode* each_vnode1; while (each_vnode1 = next_vnode1()) { VNode_list_iterator next_vnode2(*vnodelist2); VNode* each_vnode2; while (each_vnode2 = next_vnode2()) { check_shortcut(each_vnode1, each_vnode2); } check_shortcut(each_vnode1, next_vnode); } @) // this operation returns all the vnodes of the current node // except 'vnode'. *operation* VNode_ParList* all_vnodes_but(VNode* vnode) *init* (@ new VNode_ParList() @) *traverse* *from* Node *to-stop* VNode *wrapper* VNode (@ if (this != vnode) return_val->append(this); @) // add a shortcut from vnode1 to vnode2 *operation* void add_shortcut(VNode* vnode1, VNode* vnode2) *wrapper* Ring (@ VirtualAdjacency* adj1 = this->find(vnode1); adj1->add_shortcut(vnode2); @) *operation* void add_shortcut(VNode* vnode) *wrapper* VirtualAdjacency (@ VirtualNeighbor* shortcut_neigh = new VirtualNeighbor(vnode, new DemReal(0.0), new DemReal(0.0), new DemReal(0.0)); this->get_shortcuts()->append(shortcut_neigh); @) // check to see if link vnode1 to vnode2 is a shortcut link, and // if it is then add it to the ring. *operation* void check_shortcut(VNode* vnode1, VNode* vnode2) *wrapper* Ring (@ int add = 0; VirtualAdjacency* next_adj; VNode* next_vnode = vnode2; VNode* furthest_source; next_adj = this->find(vnode2); do { furthest_source = furthest_possible_source(next_vnode); if (in_ring_order(furthest_source, vnode1, next_vnode)) { add = 1; break; } next_adj = this->get_nextdefault(next_adj); next_vnode = next_adj->get_source(); }while (next_vnode != vnode1); if (add) add_shortcut(vnode1, vnode2); @)