There are many ways to design a graph data structure. All of them have tradeoffs, they can't be very good for everything.

For your benchmarks are you using the ldc2 compiler with correct compilation switches?

map() should not allocate memory.

Sometimes lazy code is faster and sometimes it's slower. A good compiler (like Haskell GHC) should be able to optimize map well.

Also try to use a bitvector from Phobos instead of bool[].

Sometimes you can keep memory allocation low, performance almost acceptable, and code easy to read using a pre-allocated scratch space plus using map() and copy() from std.algorithm.

Bye,
bearophile

Reply via email to