check if directed graph has cycle