Skip to main content

solve edge combination of group graph

Project description

group_diagram_combination

Select several edges from a set of grouped nodes to form a grouped graph (e.g., bipartite graph, tripartite graph).

Install

pip install group-diagram-combination

Usage

from group_diagram_combination import main
print(main([2, 3, 4], 2))

Problem Description

There are $K$ groups of nodes, where the $i$-th group contains $a_i$ distinct nodes (all nodes are unique). We need to connect exactly $M$ undirected edges in the graph such that:

  1. Nodes within the same group cannot be connected to each other
  2. The same edge cannot be selected twice

Calculate all valid solutions that satisfy the above constraints.

Problem Input

Given a sequence $a_i$ of length $K$, and $M$.

Problem Output

Output all valid solutions.

Input Example

[[2, 2], 2]

Output Example

[
    [[[1, 1], [2, 1]], [[1, 1], [2, 2]]],
    [[[1, 1], [2, 1]], [[1, 2], [2, 1]]],
    [[[1, 1], [2, 1]], [[1, 2], [2, 2]]],
    [[[1, 1], [2, 2]], [[1, 2], [2, 1]]],
    [[[1, 1], [2, 2]], [[1, 2], [2, 2]]],
    [[[1, 2], [2, 1]], [[1, 2], [2, 2]]],
]

Note: [i, j] denotes the $j$-th node in the $i$-th group. [[x, y], [p, q]] denotes an undirected edge between the $y$-th node in the $x$-th group and the $q$-th node in the $p$-th group. Both group numbers and node numbers start from 1.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

group_diagram_combination-0.0.2.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

group_diagram_combination-0.0.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file group_diagram_combination-0.0.2.tar.gz.

File metadata

  • Download URL: group_diagram_combination-0.0.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.13.12 Windows/11

File hashes

Hashes for group_diagram_combination-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1d63dd056298018244211d9733e7b593e32e584c26bcac84601e0a3ab9bd0462
MD5 ba8eabde04566f61ed34ab514e609ddb
BLAKE2b-256 965ad261e55fbd841d8dd0b15dd8a6e9eb1b1d8572e0cf52a8bf1ed21b8f9a6c

See more details on using hashes here.

File details

Details for the file group_diagram_combination-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for group_diagram_combination-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a40fc0dbfb6e0e9b10666ef17d55cdd5246245c65b5b84770a32374636a1894e
MD5 3ecb759dd0e3ba0a715ea483c599d9c1
BLAKE2b-256 20d06d02f0d56d80459c760e22dfd58b259074e537883d48fcfea489b9cb201f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page