File: subfams.cpp

package info (click to toggle)
libmuscle 3.7%2B4565-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,912 kB
  • sloc: cpp: 27,959; makefile: 58; sh: 26
file content (68 lines) | stat: -rw-r--r-- 1,481 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "libMUSCLE/muscle.h"
#include "libMUSCLE/distfunc.h"

namespace muscle {

const float INFINITY = float(1e29);
const unsigned NILL = uInsane;

static TLS<float *> ShortestPathEstimate;
static TLS<unsigned *> Predecessor;

static void GetMostDistantPair(DistFunc &DF, unsigned *ptrIndex1, unsigned *ptrIndex2)
	{
	const unsigned uNodeCount = DF.GetCount();
	if (uNodeCount < 2)
		Quit("GetMostDistantPair: < 2 seqs");

	float MaxDist = -1; 
	unsigned Index1 = uInsane;
	unsigned Index2 = uInsane;
	for (unsigned i = 0; i < uNodeCount; ++i)
		{
		for (unsigned j = i + 1; j < uNodeCount; ++j)
			{
			float d = DF.GetDist(i, j);
			if (d > MaxDist)
				{
				MaxDist = d;
				Index1 = i;
				Index2 = j;
				}
			}
		}

	assert(Index1 != uInsane);
	assert(Index2 != uInsane);

	*ptrIndex1 = Index1;
	*ptrIndex2 = Index2;
	}

static void InitializeSingleSource(DistFunc &DF, unsigned uIndex)
	{
	const unsigned uNodeCount = 0;

	for (unsigned i = 0; i < uNodeCount; ++i)
		{
		ShortestPathEstimate.get()[i] = INFINITY;
		Predecessor.get()[i] = NILL;
		}
	ShortestPathEstimate.get()[uIndex] = 0;
	}

static void Relax(DistFunc &DF, unsigned u, unsigned v)
	{
	float w = DF.GetDist(u, v);
	float d = ShortestPathEstimate.get()[u] + w;
	if (ShortestPathEstimate.get()[v] > d)
		{
		ShortestPathEstimate.get()[v] = d;
		Predecessor.get()[v] = u;
		}
	}

void ShortestPath(DistFunc &DF, unsigned uIndex)
	{
	}
}