top sort and graph validation implemented