restructured, completed some algorithms for graphs