in reply to Re: Sub set where all are connected
in thread Sub set where all are connected

You're right! Had done something very similar about two decades ago, although to detect loops and using Oracle PL/SQL. IMHO, the following (relational database inspired) method should work.

1. Arrange all the sets in a table in columns named FROM and TO where the smaller one is in the FROM column - if no such case there is a loop.

2. Assign all FROM's without an entry in TO as being at LEVEL = 1 and the corresponding TO as at LEVEL = 2

3. Starting from LEVEL = 2 and incrementing LEVEL by 1 until there are no further records to be assigned a LEVEL: Assign the next LEVEL to the corresponding TO

4. Start with the records with the largest LEVEL and work backwards from the previous LEVEL. Be careful when there is more than one "parent" at the previous LEVEL - multiple results.

5. If at end there are records with no LEVEL assigned, then there is a loop

Replies are listed 'Best First'.
Re^3: Sub set where all are connected
by LanX (Saint) on Nov 23, 2019 at 16:02 UTC
    I'm still puzzled if you want the connected components or the cliques of a graph.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      Sorry. The method above helps in finding the longest connection.

      Help in finding the largest clique(s) highly welcome.

Re^3: Sub set where all are connected
by Sanjay (Sexton) on Nov 23, 2019 at 16:05 UTC

    Please ignore, Wrong