Minor refactoring for erasing repeated code.

I have refactored classes AbstractBaseGraph and DirectedAcyclicGraph for avoiding repeated code.

All tests (527 + one little test more for DirectedAcyclicGraph) are ok.