practice C++ Graph Algorithm