privating topological sorting methods