// create a ring from the network. First find a spanning tree of the // graph network and then traverse the tree in order to create the // ring. *operation* Ring* create_ring() *wrapper* Network (@ Adjacency* max_adj = max_degree_adj(); cout << "***The maximum Degree node is " << *(max_adj->get_source()->get_id()) << endl; Tree* tree = max_adj->spanning_tree(this); Tree_Adjacency* root = tree->get_tree_adjacencies()->car(); Ring* ring = new Ring(new VirtualAdjacency_List(), new DemNumber(0)); root->traverse_tree(tree, ring, 0); ring->remove_lastadj(); // delete last vnode from ring this->build_jumps(tree, ring); ring->build_shortcuts(); return_val = ring; @) *operation* void print_ring() *traverse* *from* Ring *to-stop* VirtualAdjacency *wrapper* Ring (@ cout << "Number of virtual nodes: " << get_vnode_count() << endl; @) *wrapper* VirtualAdjacency (@ VNode* vnode; vnode = this->get_source(); cout << "Virtual Node: "; cout << vnode->get_vid() << "(" << vnode->get_phys_node()->get_id() << ")" << endl; cout << " util = " << get_next_util() << endl; cout << "Jumps to virtual nodes:\n"; this->print_jumps(); cout << "Shortcuts to virtual nodes:\n"; this->print_shortcuts(); @) *operation* void print_jumps() *traverse* *from* VirtualAdjacency *through* -> *, jumps, * *to-stop* VNode *wrapper* VNode (@ cout << this->get_vid() << "(" << this->get_phys_node()->get_id() << ")" << endl; @) *wrapper* VirtualNeighbor *suffix* (@ cout << " util = " << get_util() << endl; @) *operation* void print_shortcuts() *traverse* *from* VirtualAdjacency *through* -> *, shortcuts, * *to-stop* VNode *wrapper* VNode (@ cout << this->get_vid() << "(" << this->get_phys_node()->get_id() << ")" << endl; @) *wrapper* VirtualNeighbor *suffix* (@ cout << " util = " << get_util() << endl; @) // remove the last virtual adjacency from the ring *operation* void remove_lastadj() *wrapper* Ring (@ VirtualAdjacency_List* NewVirtualAdjacencies = new VirtualAdjacency_List(); VirtualAdjacency* adj; VirtualAdjacency_List* VirtualAdjacencies = get_start(); adj = VirtualAdjacencies->get(); while (VirtualAdjacencies->empty() != 0) { NewVirtualAdjacencies->append(adj); adj = VirtualAdjacencies->get(); } adj->get_phys_node()->remove_lastvnode(); this->set_start(NewVirtualAdjacencies); @) // remove the last vnode from the list of vnodes of a physical node *operation* void remove_lastvnode() *wrapper* Node (@ VNode_ParList* vnodes = this->get_vnodes(); VNode_ParList* new_vnodes = new VNode_ParList(); VNode* vnode; vnode = vnodes->get(); while (vnodes->empty() != 0) { new_vnodes->append(vnode); vnode = vnodes->get(); } this->set_vnodes(new_vnodes); @) // add a virtual node to the ring *operation* void add_vnode(int& vcount, Node* node) *wrapper* Ring (@ VNode* vnode = new VNode(new DemNumber(vcount), node); node->get_vnodes()->append(vnode); VirtualAdjacency* new_adj = new VirtualAdjacency(vnode, new DemReal(0.0), // next link util new DemReal(0.0), // next past util new DemReal(0.0), // next total flow new VirtualNeighbor_List(), //shortcuts new VirtualNeighbor_List()); //jumps this->get_start()->append(new_adj); this->get_vnode_count()->set_val(vcount); vcount++; @)