lnrpc+autopilot: add graph diameter calculation

* adds a brute force computation of the diameter
* adds a more efficient calculation of the diameter
This commit is contained in:
bitromortac
2021-12-22 11:03:03 +01:00
parent 4d9a05c2f4
commit 52d56a8990
4 changed files with 273 additions and 2 deletions

View File

@ -5904,10 +5904,20 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context,
minChannelSize = 0
}
// TODO(roasbeef): graph diameter
// Graph diameter.
channelGraph := autopilot.ChannelGraphFromDatabase(graph)
simpleGraph, err := autopilot.NewSimpleGraph(channelGraph)
if err != nil {
return nil, err
}
start := time.Now()
diameter := simpleGraph.DiameterRadialCutoff()
rpcsLog.Infof("elapsed time for diameter (%d) calculation: %v", diameter,
time.Since(start))
// TODO(roasbeef): also add oldest channel?
netInfo := &lnrpc.NetworkInfo{
GraphDiameter: diameter,
MaxOutDegree: maxChanOut,
AvgOutDegree: float64(2*numChannels) / float64(numNodes),
NumNodes: numNodes,