Move graph algorithms to separate directory