added topological sorting and test if graph is azyclical