Skip to main content

https://link.springer.com/article/10.1186/s13015-022-00213-z

Project description

This package contains an implementation of an algorithm that reduces the width of a given tree decomposition while removing a minimum number of edges. An example of use is:

    from treediet.graph_classes import Graph, Bag
    from treediet.tree_diet import tree_diet
        
    # Graph Definition
    G = Graph()
     
    for i in range(5):
        G.add_vertex(i)

    G.add_edge(0,1)
    G.add_edge(0,2)
    G.add_edge(0,3)

    G.add_edge(1,2)
    G.add_edge(1,3)

    G.add_edge(2,3)

    G.add_edge(1,4)
    G.add_edge(2,4)
    G.add_edge(3,4)

    # Tree Decomposition construction
    R = Bag([])

    B1 = Bag([0])
    B2 = Bag([0,1])
    B3 = Bag([0,1,2])
    B4 = Bag([0,1,2,3])
    B5 = Bag([1,2,3,4])

    R.add_child(B1)
    B1.add_child(B2)
    B2.add_child(B3)
    B3.add_child(B4)
    B4.add_child(B5)

    # Calling Dynamic Programming tree-diet algorithm
    OPT, real_edges, color_dictionary = tree_diet(R, G.adj, 2, [])

    print(OPT,real_edges, color_dictionary)

The output should be:

    >> 7, [(0, 1), (0, 2), (1, 2), (0, 3), (1, 3), (1, 4), (3, 4)], {1: {0: 1}, 2: {0: 1, 1: 1}, 3: {0: 1, 1: 1, 2: 1}, 4: {0: 1, 1: 1, 2: 3, 3: 1}, 5: {1: 1, 2: 3, 3: 1, 4: 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

treediet-0.2.1.tar.gz (24.8 kB view details)

Uploaded Source

Built Distributions

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

treediet-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (176.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

treediet-0.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (175.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

treediet-0.2.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (175.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file treediet-0.2.1.tar.gz.

File metadata

  • Download URL: treediet-0.2.1.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for treediet-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3a791cba505b00f425ac2c92d286045ac88d0578fd7641c62189aee021306a11
MD5 01b1b61a8faaa606c1d8c9fb51396000
BLAKE2b-256 1b1da72c141b1b6f96ac1663b327de1bc66b3bcc9b1ddff3036dd41b57446cf8

See more details on using hashes here.

File details

Details for the file treediet-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for treediet-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 88aff5a36b49ff40bfb9829e6db9ad5429b8450f1413de2e5f2c7d9d92c99d56
MD5 8105044c4c83876b974c428fb936a95c
BLAKE2b-256 a16e42f26ed9d83f043d01efcca208ad4e4265ed5d9cf3ce7daae8701e1a7e18

See more details on using hashes here.

File details

Details for the file treediet-0.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for treediet-0.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 736b92d44a8cc093e68e2de29a2a1909d32e8964caf33c2e7a65ffedc2d26659
MD5 39f67d26e9077d51e0e537ddf2947597
BLAKE2b-256 6d19c87fc3ef7dcc6884d95234a7460234806ccb535e9b906b6e7e8595ee274f

See more details on using hashes here.

File details

Details for the file treediet-0.2.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for treediet-0.2.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 edf4a14def2d7b35786ba283febb95f088030c7ac120312f20ab6eaab3c92470
MD5 fd5a7f0fd30d7726bdb28bbbfbc4f44c
BLAKE2b-256 778c3fbb4b5b856308573377cacdedaacb61a15e0be43d0db4c5e1175f20304e

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