Commit d4c4baa8 authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Modified distributed dijkstra to work correctly in the presence of a non-connected graph.

parent bedfcbeb
......@@ -71,31 +71,27 @@ void Compressor::compress(SingleSource const & newGraph,
void Compressor::add(int dest, IPAddress destIp)
{
int firstHop = graph->getFirstHop(dest);
if ((destIp >> shift_10) == ip_10)
HostEntry::const_iterator pos;
pos = (*ipMap)[graph->getSource()].find(firstHop);
if (pos != (*ipMap)[graph->getSource()].end())
{
root_10.addRoute(destIp, firstHop, IP_SIZE - shift_10);
}
else if ((destIp >> shift_172_16) == ip_172_16)
{
root_172_16.addRoute(destIp, firstHop, IP_SIZE - shift_172_16);
}
else if ((destIp >> shift_192_168) == ip_192_168)
{
root_192_168.addRoute(destIp, firstHop, IP_SIZE - shift_192_168);
}
else
{
HostEntry::const_iterator pos;
pos = (*ipMap)[graph->getSource()].find(firstHop);
if (pos != (*ipMap)[graph->getSource()].end())
if ((destIp >> shift_10) == ip_10)
{
// TODO: Figure out what cost means
printRouteToIp(pos->second.first, pos->second.second,
ipToString(destIp), 1);
root_10.addRoute(destIp, firstHop, IP_SIZE - shift_10);
}
else if ((destIp >> shift_172_16) == ip_172_16)
{
root_172_16.addRoute(destIp, firstHop, IP_SIZE - shift_172_16);
}
else if ((destIp >> shift_192_168) == ip_192_168)
{
root_192_168.addRoute(destIp, firstHop, IP_SIZE - shift_192_168);
}
else
{
throw StringException("Internal error: Corruption in data structures: Compressor::add()");
// TODO: Figure out what cost means
printRouteToIp(pos->second.first, pos->second.second,
ipToString(destIp), 1);
}
}
}
......
......@@ -51,7 +51,7 @@ void SingleSource::route(int newSource)
first_hop[source] = source;
for (int i = 0; i < static_cast<int>(first_hop.size()); ++i)
{
if (i != source)
if (i != static_cast<int>(pred_map[i]))
{
int current = i;
while(static_cast<int>(pred_map[current]) != source)
......@@ -60,6 +60,10 @@ void SingleSource::route(int newSource)
}
first_hop[i] = current;
}
else
{
first_hop[i] = i;
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment