- Graph closure fixed.

This commit is contained in:
ccremers 2004-10-28 15:37:13 +00:00
parent 0ec70b9de0
commit aaa0d415f9

View File

@ -58,34 +58,34 @@ graph_display (int *graph, int nodes)
int
warshall (int *graph, int nodes)
{
int i;
int k;
int index (const int i, const int j)
int index (const int x, const int y)
{
return (i * nodes + j);
return (x * nodes + y);
}
k = 0;
while (k < nodes)
{
int i;
i = 0;
while (i < nodes)
{
if (graph[index (i, k)] == 1)
{
int j;
j = 0;
while (j < nodes)
{
if (graph[index (j, i)] == 1)
{
int k;
k = 0;
while (k < nodes)
{
if (graph[index (k, j)] == 1)
{
if (k == i)
if (i == j)
{
// Oh no! A cycle.
graph[index (k, i)] = 2;
graph[index (i, j)] = 2;
#ifdef DEBUG
if (DEBUGL (5))
{
@ -94,15 +94,15 @@ warshall (int *graph, int nodes)
#endif
return 0;
}
graph[index (k, i)] = 1;
}
k++;
}
graph[index (i, j)] = 1;
}
j++;
}
}
i++;
}
k++;
}
return 1;
}