autopilot: parallelize betweenness centrality

This commit parallelizes betweenness centrality calculation, by
distributing the algo to N workers and creating partial results.
This commit is contained in:
Andras Banki-Horvath committed 2020-03-27 13:56:10 +01:00
1 parent 7e50997bb4
commit 608354032c
3 files changed
+136 -46

No files matched your search

+7 -1
View File
@@ -10,6 +10,7 @@ import (
"io"
"math"
"net/http"
"runtime"
"sort"
"strings"
"sync"
@@ -4693,7 +4694,12 @@ func (r *rpcServer) GetNodeMetrics(ctx context.Context,
// Calculate betweenness centrality if requested. Note that depending on the
// graph size, this may take up to a few minutes.
channelGraph := autopilot.ChannelGraphFromDatabase(graph)
centralityMetric := autopilot.NewBetweennessCentralityMetric()
centralityMetric, err := autopilot.NewBetweennessCentralityMetric(
runtime.NumCPU(),
)
if err != nil {
return nil, err
}
if err := centralityMetric.Refresh(channelGraph); err != nil {
return nil, err
}