2

I am trying to calculate a transitive closure of a graph. Let`s consider this graph as an example (the picture depicts the graph, its adjacency and connectivity matrix): enter image description here

Using Warshall's algorithm, which i found on this page, I generate this connectivity matrix (=transitive closure?), that is different from the one in the picture:

 01111
 01111
 01011
 01111
 01111

I have also tried using this applet which also gives me a different result:

01111
01111
01111
01111
01111

So I'm a little confused right now, since I don't know which matrix is the right one. Can someone shed some light on my problem?

TheAptKid
  • 1,559
  • 3
  • 25
  • 47

1 Answers1

2

C(1,1): The letter T at C(1,1) implies that there should be Ts on the diagonal of A.

C(3,3): One round of the Warshall algorithm only seems to find reachable nodes at a depth of two. Since it takes three edges to reach node number three from itself, one round is not enough.

andyn
  • 577
  • 1
  • 6
  • 18
  • 1
    Thank you. I ran the algorithm on the output of the first iteration and than I got a result, which is the same as the result of the applet. I have two more questions though:1) Am I right if I say, that I must run the algorithm n-1 times to generate the transitive closure? 2) Every graph will have T on the diagonal of the matrix (every node can go to itself in 0 steps)? – TheAptKid Nov 18 '12 at 09:50
  • 1) N-1 times is enough. 2) If you look at the graph, there is simply no way to reach node 1 from other nodes than the node itself. Having ones on the diagonal means that the nodes are accessible from themselves. – andyn Nov 18 '12 at 17:38