Graph implementation in C++