I need a new set pair of eyes on this, for some reason its not generating the correct Sequence and Distance matrices the following is my implementation.
This is in C# and DistanceMatrix is a double [,] and SequenceMatrix is a string [,]
these are initiated as follows: http://puu.sh/951Tz/5ef27e3996.png
for (int k = 0; k < villageCount; k++)
{
for (int i = 0; i < villageCount; i++)
{
if (k == i)
continue;
for (int j = 0; j < villageCount; j++)
{
if (j == i)
continue;
if (j == k)
continue;
if (fw.DistanceMatrix[i, j] >= (fw.DistanceMatrix[i, k] + fw.DistanceMatrix[k, j]))
{
fw.DistanceMatrix[i, j] = (fw.DistanceMatrix[i, k] + fw.DistanceMatrix[k, j]);
fw.SequenceMatrix[i, j] = fw.SequenceMatrix[k, j];
}
}
}
}
for some reason I'm getting the following output:
[0, 0] "A" string
[0, 1] "B" string
[0, 2] "A" string
[0, 3] "B" string
[0, 4] "D" string
[1, 0] "B" string
[1, 1] "D" string
[1, 2] "D" string
[1, 3] "B" string
[1, 4] "D" string
[2, 0] "B" string
[2, 1] "B" string
[2, 2] "B" string
[2, 3] "B" string
[2, 4] "D" string
[3, 0] "B" string
[3, 1] "B" string
[3, 2] "C" string
[3, 3] "C" string
[3, 4] "D" string
[4, 0] "B" string
[4, 1] "E" string
[4, 2] "D" string
[4, 3] "B" string
[4, 4] "E" string
any pointers would be much appreciated, also if you require more information i'll be F5ing this page :)
distance matrix after init
[0, 0] 0.0 double
[0, 1] 50.0 double
[0, 2] 2.0 double
[0, 3] 10.0 double
[0, 4] 1.7976931348623157E+308 double
[1, 0] 50.0 double
[1, 1] 0.0 double
[1, 2] 3.0 double
[1, 3] 1.7976931348623157E+308 double
[1, 4] 1.0 double
[2, 0] 2.0 double
[2, 1] 3.0 double
[2, 2] 0.0 double
[2, 3] 5.0 double
[2, 4] 5.0 double
[3, 0] 10.0 double
[3, 1] 1.7976931348623157E+308 double
[3, 2] 5.0 double
[3, 3] 0.0 double
[3, 4] 1.7976931348623157E+308 double
[4, 0] 1.7976931348623157E+308 double
[4, 1] 1.0 double
[4, 2] 5.0 double
[4, 3] 1.7976931348623157E+308 double
[4, 4] 0.0 double