Basic graph problem solver in C++