I have an array in which in each row , all the vertices are connected.

eg: 0 3 4

6 2 0

1 2 5

here there is a direct path in between each of the two nodes in each row

if we take row1: 0 is connected with 3 , 4 and 3 is connected with 4

the graph is undimentional

what I did is to convert it into a n*n matrix and applied Floyd–Warshall algorithm

but as its efficieny is o(n^3).As solution set is large. Its taking long time.

Can you suggest me a better solution.

thank you

Can you post the link to the problem you are trying to solve? And you only have to find the shortest path between the nodes in each row… Is that right?

No.

All the nodes in each row are connected with each other with each other with weight=0

I want to find the shortest word chain for a set of words

cat->mat>map->tap

lets say it is the shortest chain between cat and tap

I construct a dictionary(hash table) where keys are in form

*at:cat,mat,bat,…
c*t:…

ca*:cap,…

…so on

here cat and mat are in one row and are directly connected as they differ by exactly differ by one character.

i think you’ll have to make your statement a little bit more “formal” for us to understand exactly what kind of solution you expect.