implementaion of basic graph algo in cpp