Range-Based Graph Search in D (blog post)

Peter Alexander peter.alexander.au at gmail.com
Thu Jan 9 14:58:54 PST 2014


On Thursday, 9 January 2014 at 22:54:11 UTC, bearophile wrote:
> Peter Alexander:
>
>> http://poita.org/2014/01/09/range-based-graph-search-in-d.html
>
> I'd like to see the usage of a not implicit graph.

There is a crude example in the unit test in the file.

You could actually create an non-implicit graph using 
implicitGraph:

auto adjacencyLists[nVerts] = [...];
auto graph = implicitGraph!(int, i => adjList[i]);


> Regarding this line:
>
> static d(string a, string b) { return zip(a, b).count!"a[0] != 
> a[1]"; }
>
> An alternative:
>
> enum dist = (in string s, in string s2) pure =>
>     s1.zip(s2).count!(ab => ab[0] != ab[1]);

True, I tried to make it as short as possible so it fit on one 
line in my blog :-)



More information about the Digitalmars-d-announce mailing list