SRM 582
Refactoring of graph library.