If I have a class like this:
class Component (val name, val description, var subElements : Set[Component])
How can I test if a Component contains cycles inside (with a Boolean function) and who started this cycle.
I know well that if I use val instead of var avoid cycles, but I cannot use val.
A member of
Componentto return all elements in the graph below which start a cycle. It returns an empty set if there are no cycles.