Skip to content

Commit

Permalink
Correction for rooted trees
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericlemoine committed May 22, 2020
1 parent e378ab1 commit b223049
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions support/fbp.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,21 @@ func FBP(reftree *tree.Tree, boottrees <-chan tree.Trees, cpus int, sup *Support
var ntrees int32 = 0
foundEdges := make(chan int, 100)
foundBoot := make([]int, len(edges))
edgeIndex := tree.NewEdgeIndex(uint64(len(edges)*2), 0.75)
for i, e := range edges {
for _, e := range edges {
if !e.Right().Tip() {
e.Right().SetName("")
}
if !e.Left().Tip() {
e.Left().SetName("")
}
if err = edgeIndex.PutEdgeValue(e, i, e.Length()); err != nil {
return err
}
}
var wg sync.WaitGroup
for cpu := 0; cpu < cpus; cpu++ {
wg.Add(1)
go func(cpu int) {
var inerr error
for treeV := range boottrees {
edgeIndex := tree.NewEdgeIndex(uint64(len(edges)*2), 0.75)
if sup.Canceled() {
break
}
Expand All @@ -65,14 +62,20 @@ func FBP(reftree *tree.Tree, boottrees <-chan tree.Trees, cpus int, sup *Support
}
atomic.AddInt32(&ntrees, 1)
edges2 := treeV.Tree.Edges()
for _, e2 := range edges2 {
for i, e2 := range edges2 {
if !e2.Right().Tip() {
val, ok := edgeIndex.Value(e2)
if ok {
foundEdges <- val.Count
if inerr = edgeIndex.PutEdgeValue(e2, i, e2.Length()); inerr != nil {
err = inerr
return
}
}
}
for i, e := range edges {
_, ok := edgeIndex.Value(e)
if ok {
foundEdges <- i
}
}
}
sup.IncrementProgress()
}
Expand All @@ -85,12 +88,13 @@ func FBP(reftree *tree.Tree, boottrees <-chan tree.Trees, cpus int, sup *Support
close(foundEdges)
}()

for edge_i := range foundEdges {
foundBoot[edge_i]++
for edgeI := range foundEdges {
foundBoot[edgeI]++
}

for i, count := range foundBoot {
if !edges[i].Right().Tip() {
//fmt.Printf("%d: %d/%d\n", i, count, ntrees)
edges[i].SetSupport(float64(count) / float64(ntrees))
}
}
Expand Down

0 comments on commit b223049

Please sign in to comment.