// find the commodities in the traffic matrix *operation* Commodity_List* find_commodities(Node_List* nodelist, Ring* ring) *init* (@ new Commodity_List() @) *traverse* *from* InputNetwork *through* -> *, neighbors, * *to-stop* InputNode *carry* *in* Node* source_node *along* *from* InputAdjacency *through* -> *, neighbors, * *to-stop* InputNode *carry* *in* DemReal* traffic *along* *from* InputNeighbor *to-stop* InputNode *at* InputNeighbor traffic = (@ get_capacity() @) *wrapper* InputAdjacency (@ int pos = nodelist->id_member(get_source()); source_node = nodelist->n_th(pos); @) *wrapper* InputNode (@ int pos = nodelist->id_member(this); Node* dest_node = nodelist->n_th(pos); VNode *source_vnode, *dest_vnode; ring->distance(source_node, dest_node, source_vnode, dest_vnode); Commodity* com = return_val->dest_member(dest_vnode); VNodeTraff* new_vnodetraff = new VNodeTraff(source_vnode, traffic); if (com == NULL) { com = new Commodity(dest_vnode, new VNodeTraff_List()); com->get_sources()->append(new_vnodetraff); return_val->append(com); } else { com->get_sources()->append(new_vnodetraff); } @) // return the Commodity that has destination "vnode". *operation* Commodity* dest_member(VNode* vnode) *init* (@ NULL @) *traverse* *from* Commodity_List *through* -> *, dest, * *to-stop* VNode *carry* *in* Commodity* com *along* *from* Commodity *through* -> *, dest, * *to-stop* VNode *at* Commodity com = (@ this @) *wrapper* VNode (@ if (this == vnode) return_val = com; @) *operation* void print_commodities() *traverse* *from* Commodity_List *to* VNodeTraff *wrapper* Commodity (@ cout << "Commodity: " << get_dest()->get_vid() << endl; @) *wrapper* VNodeTraff (@ cout << " " << get_source()->get_vid() << " with " << get_traffic() << endl; @)