Warshall algorithm - transitive closure helper
Need help with transitive closure of relation or graph? With this program/tool
you can calculate the transitive closure of graph. It tells you stepp by stepp,
if the step transforms the matrix, what it does. The relation is represented by
an adjacency matrix. You can enter a matrix, max size of 10, with a 1 in cell [i,j]
if the relation iRj exsist and a 0 if the relations doesnt exsist.
Warshall a theorem on boolean matrices
I have used the following algorithms (C# .NET):
private Boolean[][] WarshallsAlgorithm(Boolean[][] Matrix)
{
Boolean[][] adj = null;
adj = new Boolean[N][];
int i, j, k;
for (i = 1; i <= N; i++)
{
adj[i] = new Boolean[N];
for (j = 1; j <= N; j++)
{
adj[i][j] = Matrix[i][j];
}
}
for (k = 1; k <= N; k++)
{
for (i = 1; i <= N; i++)
{
for (j = 1; j <= N; j++)
{
adj[i][j] = (adj[i][j] || (adj[i][k] && adj[k][j]));
}
}
}
return adj;
}
Sybren Roede (3 November 2009)