예제 #1
0
void NetworkManager::cleanUpLinks(Links & links, Assignment * assignment)
{
    for ( Links::iterator l = links.begin(); l != links.end(); l++ )
    {
        NetPath path = assignment->GetAssignment(*l);
        if ( !path.empty() )
            removeAssignment(*l, path);

        assignment->RemoveAssignment(*l);
    }
}
void DijkstraRouter::printPath(const NetPath & path) const
{
    if ( path.empty() )
        return;

    for ( NetPath::const_iterator i = path.begin(); i != path.end(); i++)
    {
        Element * element = *i;
        printf("%s:%lu", element->getName().c_str(), element->getID());
        if ( i + 1 != path.end() )
            printf(" -> ");
    }
    printf("\n");
}
예제 #3
0
Algorithm::Result NetworkManager::buildPath(Element * from, Element * to, Link * vlink, Assignment * assignment)
{
    if ( from == to )
        return Algorithm::SUCCESS;

    cerr << "[NM]\tBuilding path" << endl;
    Link * dummy = new Link("dummy", vlink->getCapacity(), vlink->getMaxCapacity());
    dummy->bindElements(from, to);
    NetPath path = VirtualLinkRouter::routeDejkstra(dummy, &network);
    delete dummy;

    if ( path.empty() )
        return Algorithm::FAILURE;

    addAssignment(vlink, path);
    assignment->AddAssignment(vlink, path);
    cerr << "[NM]\tPath building succedeed" << endl;
    return Algorithm::SUCCESS;
}