Hey there,
I need some help in Warshall Algo coding in C++
Question:
Input a matrix of (n x n).
Example:
Let A be the input martix (Direct Paths)
0 1 0 0
0 0 1 1
0 0 0 0
1 0 1 0
We have to figure out the possible paths in the graph.
The output matrix should be
1 1 1 1
1 1 1 1
0 0 0 0
1 1 1 1
To see the graph, click the link below:
http://i15.tinypic.com/2lbdd0j.gif
Please contact me at taalzz @ gmail.com
Thanks!
Help in Warshall Algorithm (C++ Coding)?
Telling you the function, just call this function from main().
void transclose( int adj[ ][MAXNODES], int path[ ][MAXNODES] )
{
int i,j,k ;
for( i=0 ; i%26lt;MAXNODES ; ++i )
for( j=0 ; j%26lt;MAXNODES ; ++j )
path[i][j] = adj[i][j] ;
for( k=0 ; k%26lt;MAXNODES ; ++k )
for( i=0 ; i%26lt;MAXNODES ; ++i)
if( path[i][k] == TRUE )
for( j=0 ; j%26lt;MAXNODES ; ++j )
path[i][j] = path[i][j] || path[k][j] ;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment