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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

treediet-0.2.0-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.0-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.0-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.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for treediet-0.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 aa9de44b6eef9000c0cd366ede182b1e5c6da65be01ffcfa341eb520c22e97d7
MD5 bd50cd10a21bec9939ceeeae203cf45b
BLAKE2b-256 6e966a41105010a9eec2799bb64cf88f12f771c8e33ff87d7c22e98abb44fb7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for treediet-0.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ef3e20852310326d545a66910d5e8a795d0c82ad22a7d8f2c4e31869b87dda91
MD5 75c190e0d811cf538a902c328d9d05ff
BLAKE2b-256 be00beed82030dea451cdd0294df5b23470631392b21c15baa21e848139d4952

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for treediet-0.2.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 697f8b6083d8853dc7b9e7ea52033387bda7474cd75575b8a5644ee603326113
MD5 c71b7a5ca852c6618893e4ac189220ac
BLAKE2b-256 e627bb3d6d5ef7041c9101fee6a82fb4d8d6d57f735585f772b214e8c332bd08

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