Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9026773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:36:10+00:00 2026-06-16T06:36:10+00:00

Introduction While trying to do some cathegorization on nodes in a graph (which will

  • 0

Introduction

While trying to do some cathegorization on nodes in a graph (which will be rendered differenty), I find myself confronted with the following problem:

The Problem

Given a superset of elements S = {0, 1, ... M} and a number n of non-disjoint subsets T_i thereof, with 0 <= i < n, what is the best algorithm to find out the partition of the set S called P?

P = S is the union of all disjoint partitions P_j of the original superset S, with 0 <= j < M, such that for all elements x in P_j, every x has the same list of “parents” among the “original” sets T_i.

Example

S = [1, 2, 3, 4, 5, 6,   8, 9]

T_1 = [1, 4]
T_2 = [2, 3]
T_3 = [1, 3, 4]

So all P_js would be:

P_1 = [1, 4] # all elements x have the same list of "parents": T_1, T_3
P_2 = [2] # all elements x have the same list of "parents": T_2
P_3 = [3] # all elements x have the same list of "parents": T_2, T_3
P_4 = [5, 6, 8, 9] #  all elements x have the same list of "parents": S (so they're not in any of the P_j

Questions

  1. What are good functions/classes in the python packages to compute all P_js and the list of their “parents”, ideally restricted to numpy and scipy? Perhaps there’s already a function which does just that
  2. What is the best algorithm to find those partitions P_js and for each one, the list of “parents”? Let’s note T_0 = S

I think the brute force approach would be to generate all 2-combinations of T sets and split them in at most 3 disjoint sets, which would be added back to the pool of T sets and then repeat the process until all resulting Ts are disjoint, and thus we’ve arrived at our answer – the set of P sets. A little problematic could be caching all the “parents” on the way there.

I suspect a dynamic programming approach could be used to optimize the algorithm.

Note: I would have loved to write the math parts in latex (via MathJax), but unfortunately this is not activated 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T06:36:11+00:00Added an answer on June 16, 2026 at 6:36 am

    The following should be linear time (in the number of the elements in the Ts).

    from collections import defaultdict
    
    S = [1, 2, 3, 4, 5, 6,   8, 9]
    
    T_1 = [1, 4]
    T_2 = [2, 3]
    T_3 = [1, 3, 4]
    
    Ts = [S, T_1, T_2, T_3]
    
    parents = defaultdict(int)
    for i, T in enumerate(Ts):
        for elem in T:
            parents[elem] += 2 ** i
    
    children = defaultdict(list)
    for elem, p in parents.items():
        children[p].append(elem)
    
    print(list(children.values()))
    

    Result:

    [[5, 6, 8, 9], [1, 4], [2], [3]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Introduction I have been so annoyed by applications that have a startup dialog which
Introduction: I'm trying to get additional fields to log with log4j, and its working
Introduction We have an OpenID Provider which we created using the DotNetOpenAuth component. Everything
Introduction I have some sort of values that I might want to access several
Recently, while I was writing a brief introduction to C for Fortran programmers, one
I have code such as void myfunc() { introduction(); while(condition()) { complex(); loop(); interior();
While studying the book Introduction to Algorithms by Cormen, I found a strange thing.
Introduction: I have a flat ArrayCollection of object's, which i group to create the
So I'm relearning java and it's been a while since. I'm trying to build
I need some help to complete my idea about regexes. Introduction There was a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.