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.1.tar.gz (2.8 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.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: group_diagram_combination-0.0.1.tar.gz
  • Upload date:
  • Size: 2.8 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.1.tar.gz
Algorithm Hash digest
SHA256 7e6ee333544c9a1715101cfe006d01619dd4dd42b75a9b7f2e9fc7069df6bc3e
MD5 6596c6103f605c42624859605f9a70d9
BLAKE2b-256 dbd12fafd064a306860e5494f6df75d6d732e7fba0964380defad201d72caf48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for group_diagram_combination-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bad59b133586d46ef44e1acdd0aacb7d39a74c328a288fa19b9fc6e2adf2f628
MD5 5d42b51cbf5a8bc7e6e1c2d47e1126e0
BLAKE2b-256 aa77cd731f804fc95fce7824ac0ed7996b2a2ea01026f3e44f4b0c0dfa7cee58

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