in reply to Sub set where all are connected

> This seems more a Graph problem than a Set problem.

see Connected component (graph theory)

> Surprised that this problem is not common

Au contraire! Quite trivial.

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

Replies are listed 'Best First'.
Re^2: Sub set where all are connected
by Sanjay (Sexton) on Nov 23, 2019 at 15:58 UTC

    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

      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.

      Please ignore, Wrong