Skip to content

Commit 111eb09

Browse files
committed
Reverse BFS order
1 parent 7cd7234 commit 111eb09

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

result/sims/neighbor_joining/results_m5.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,32 @@ mS,8,Neighbor joining,8
1111
mS,9,Neighbor joining,3
1212
S,0,Neighbor joining,11
1313
S,12,Neighbor joining,9
14+
S,15,Neighbor joining,10
15+
S,17,Neighbor joining,6
16+
S,2,Neighbor joining,8
17+
S,23,Neighbor joining,11
18+
S,3,Neighbor joining,9
19+
S,4,Neighbor joining,11
20+
S,5,Neighbor joining,12
21+
S,9,Neighbor joining,12
22+
M,132,Neighbor joining,14
23+
M,134,Neighbor joining,16
24+
M,141,Neighbor joining,12
25+
M,152,Neighbor joining,17
26+
M,209,Neighbor joining,16
27+
M,45,Neighbor joining,13
28+
M,5,Neighbor joining,10
29+
M,50,Neighbor joining,10
30+
M,7,Neighbor joining,14
31+
M,73,Neighbor joining,15
32+
R,17,Neighbor joining,15
33+
R,2057,Neighbor joining,8
34+
R,2093,Neighbor joining,13
35+
R,2155,Neighbor joining,16
36+
R,2438,Neighbor joining,8
37+
R,2574,Neighbor joining,8
38+
R,2627,Neighbor joining,12
39+
R,2992,Neighbor joining,16
40+
R,3178,Neighbor joining,10
41+
R,325,Neighbor joining,7
42+
R,442,Neighbor joining,11

src/simulation/celltree.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "celltree.h"
99
#include "beta_distribution.hpp"
10+
#include <lemon/bfs.h>
1011

1112
CellTree::CellTree(double K,
1213
double migrationRate,
@@ -1389,6 +1390,25 @@ void CellTree::constructSampledCloneTree()
13891390
}
13901391
}
13911392

1393+
// Find right order of arcs, reverse BFS order
1394+
IntNodeMap dist(_pCloneTT->tree(), -1);
1395+
lemon::bfs(_pCloneTT->tree()).distMap(dist).run(_pCloneTT->root());
1396+
int max_dist = lemon::mapMaxValue(_pCloneTT->tree(), dist);
1397+
ArcVector arcs;
1398+
while (max_dist > 0)
1399+
{
1400+
for (NodeIt v_i(_pCloneTT->tree()); v_i != lemon::INVALID; ++v_i)
1401+
{
1402+
if (dist[v_i] == max_dist)
1403+
{
1404+
Arc inArc = InArcIt(_pCloneTT->tree(), v_i);
1405+
assert(inArc != lemon::INVALID);
1406+
arcs.push_back(inArc);
1407+
}
1408+
}
1409+
--max_dist;
1410+
}
1411+
13921412
// construct vertex labeling
13931413
for (ArcIt aa(_G); aa != lemon::INVALID; ++aa)
13941414
{
@@ -1398,7 +1418,7 @@ void CellTree::constructSampledCloneTree()
13981418
const int t = _anatomicalSiteMap[v_t];
13991419

14001420
// find matching migration edge in T
1401-
for (ArcIt a(_pCloneTT->tree()); a != lemon::INVALID; ++a)
1421+
for (Arc a : arcs)
14021422
{
14031423
Node v_i = _pCloneTT->tree().source(a);
14041424
Node v_j = _pCloneTT->tree().target(a);

0 commit comments

Comments
 (0)