Implementing and optimizing a simple graph metric

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Wed Sep 18 10:36:13 PDT 2013


On Wednesday, 18 September 2013 at 13:39:29 UTC, bearophile wrote:
> - Try to optionally accept the buffers from outside.

Does this look good to you?

/////////////////////////////////////////////////

auto ref betweenness(T = double, Graph)(ref Graph g, bool[] 
ignore = null)
     if (isFloatingPoint!T && isGraph!Graph)
{
     T[] centrality = new T[g.vertexCount];
     return betweenness!(T, Graph)(g, centrality, ignore);
}

auto ref betweenness(T = double, Graph)(ref Graph g, ref T[] 
centrality, bool[] ignore = null)
{
     centrality.length = g.vertexCount;
     centrality[] = to!T(0);
     // ... the rest as before
}

/////////////////////////////////////////////////


More information about the Digitalmars-d-announce mailing list