could you please clarify, in your example, why cycles like '1->2->1', '1->5->1' or '3->5->3' are not counted?
it seems the expected solution only counts cycles that include three or more nodes... is this correct?
That is correct. In a directed graph, the cycle 1 -> 2 -> 1 actually uses two different edges, while in an undirected graph, the edge 1 -> 2 and 2 -> 1 are one and the same. I am only considering cycles valid if each node along the way is visited once and if edges are not used more than one time. I chose this criteria so that the number of cycles counted would match the results for the table provided here: http://mathworld.wolfram.com/GraphCycle.html
got it. Thanks for the clarification!
Can you please send me your code for this??? Really struggling on this for a school assignment firstname.lastname@example.org
Knight's Tour Checker
Project Euler: Problem 7, Nth prime
Length of the hypotenuse
Sum the Digits of a Number
Count the Number of Directed Cycles in a Graph
The Answer to Life, the Universe, and Everything
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office