Directed acyclic graph implementation in C++