Number of cycles in a directed graph