| 1 | #include "muscle.h" |
|---|
| 2 | #include "distfunc.h" |
|---|
| 3 | |
|---|
| 4 | const float INFINITY = float(1e29); |
|---|
| 5 | const unsigned NILL = uInsane; |
|---|
| 6 | |
|---|
| 7 | static float *ShortestPathEstimate; |
|---|
| 8 | static unsigned *Predecessor; |
|---|
| 9 | |
|---|
| 10 | static void GetMostDistantPair(DistFunc &DF, unsigned *ptrIndex1, unsigned *ptrIndex2) |
|---|
| 11 | { |
|---|
| 12 | const unsigned uNodeCount = DF.GetCount(); |
|---|
| 13 | if (uNodeCount < 2) |
|---|
| 14 | Quit("GetMostDistantPair: < 2 seqs"); |
|---|
| 15 | |
|---|
| 16 | float MaxDist = -1; |
|---|
| 17 | unsigned Index1 = uInsane; |
|---|
| 18 | unsigned Index2 = uInsane; |
|---|
| 19 | for (unsigned i = 0; i < uNodeCount; ++i) |
|---|
| 20 | { |
|---|
| 21 | for (unsigned j = i + 1; j < uNodeCount; ++j) |
|---|
| 22 | { |
|---|
| 23 | float d = DF.GetDist(i, j); |
|---|
| 24 | if (d > MaxDist) |
|---|
| 25 | { |
|---|
| 26 | MaxDist = d; |
|---|
| 27 | Index1 = i; |
|---|
| 28 | Index2 = j; |
|---|
| 29 | } |
|---|
| 30 | } |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | assert(Index1 != uInsane); |
|---|
| 34 | assert(Index2 != uInsane); |
|---|
| 35 | |
|---|
| 36 | *ptrIndex1 = Index1; |
|---|
| 37 | *ptrIndex2 = Index2; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | static void InitializeSingleSource(DistFunc &DF, unsigned uIndex) |
|---|
| 41 | { |
|---|
| 42 | const unsigned uNodeCount = 0; |
|---|
| 43 | |
|---|
| 44 | for (unsigned i = 0; i < uNodeCount; ++i) |
|---|
| 45 | { |
|---|
| 46 | ShortestPathEstimate[i] = INFINITY; |
|---|
| 47 | Predecessor[i] = NILL; |
|---|
| 48 | } |
|---|
| 49 | ShortestPathEstimate[uIndex] = 0; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | static void Relax(DistFunc &DF, unsigned u, unsigned v) |
|---|
| 53 | { |
|---|
| 54 | float w = DF.GetDist(u, v); |
|---|
| 55 | float d = ShortestPathEstimate[u] + w; |
|---|
| 56 | if (ShortestPathEstimate[v] > d) |
|---|
| 57 | { |
|---|
| 58 | ShortestPathEstimate[v] = d; |
|---|
| 59 | Predecessor[v] = u; |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | void ShortestPath(DistFunc &DF, unsigned uIndex) |
|---|
| 64 | { |
|---|
| 65 | } |
|---|