graph building in cpp works