Algorithm for generating a tree decomposition
Asked Answered
W

1

7

I want to construct a tree decomposition: http://en.wikipedia.org/wiki/Tree_decomposition and I have the chordal graph and a perfect elimination ordering. I am following advice given in a previous thread, namely:

To construct a non-nice (in general) tree decomposition of a chordal graph: find a perfect elimination ordering, enumerate the maximal cliques (the candidates are a vertex and the neighbors that appear after it in the ordering), use each clique as a decomposition node and connect it to the next clique in the ordering that it intersects.

This does not work however and I can not figure out why. Consider the following example:

Perfect elimination ordering:

['4', '3', '5', '7', '6', '2', '0', '1']

Chordal graph:

enter image description here

Tree decomposition:

enter image description here

I am using python and my current algorithm is the following:

T=nx.Graph()
    nodelist=[]
    for i in eo:
        vertex=str(i)
        bag=set()
        bag.add(vertex)
        for j in chordal_graph.neighbors(str(i)):
            bag.add(str(j))
        T.add_node(frozenset(bag))
        nodelist.append(frozenset(bag))
        chordal_graph.remove_node(str(i))
    for node1 in range(len(nodelist)):
        found=False
        for node2 in range(node1+1,len(nodelist)):
            if found==False and len(nodelist[node1].intersection(nodelist[node2]))>0:
                T.add_edge(nodelist[node1],nodelist[node2])
                found=True
    nx.draw(T)
    p.show()     

where eo is a list of the perfect ordering and 'chordal_graph' is a graph object for networkx.

Wive answered 19/5, 2014 at 12:24 Comment(0)
C
2

So that was my (bad, as it turns out) advice. Your tree decomposition has some cliques that aren't maximal, i.e., {2, 0, 1}, {0, 1}, and {1}. The list of candidate cliques is

{4, 5, 6} (maximal)
{3, 2} (maximal)
{5, 6, 2, 0} (maximal)
{7, 2, 1} (maximal)
{6, 2, 0, 1} (maximal)
{2, 0, 1} (not maximal: subset of {6, 2, 0, 1})
{0, 1} (not maximal: subset of {6, 2, 0, 1})
{1} (not maximal: subset of {6, 2, 0, 1})

Then the decomposition should look like

                {3, 2}
                  |
{4, 5, 6}----{5, 6, 2, 0}
                  |
             {7, 2, 1}
                  |
             {6, 2, 0, 1},

which is wrong as well, since the 0 vertices aren't connected. Sorry about that.

What I should have done is to set aside the maximality condition for the moment and to connect each clique K to the next candidate seeded with a vertex belonging to K. This ensures that every vertex in K that exists in at least one other subsequent clique also appears in the target of the connection. Then the decomposition looks like this

{4, 5, 6}----{5, 6, 2, 0}
                  |
             {6, 2, 0, 1}
                  |
   {3, 2}----{2, 0, 1}----{7, 2, 1}
                  |
                {0, 1}
                  |
                {1}

and you can splice out the non-maximal cliques by checking, for each clique in reverse order, whether it's a superset of its parent, and if so, reparenting its parent's children to it.

{4, 5, 6}----{5, 6, 2, 0}
                  |
   {3, 2}----{6, 2, 0, 1}----{7, 2, 1}
Cabman answered 19/5, 2014 at 13:56 Comment(5)
Hi. Could you please explain this ``to connect each clique K to the next candidate seeded with a vertex belonging to K.''? What do you mean by the next candidate seeded with a vertex belong to K? If that means they have intersect, why does {4,5,6} not connected to {6,2,0,1}? Thanks.Graduation
By "a clique seeded with a vertex v" I meant the clique comprised of v and the neighbors of v that appear after v in the perfect elimination ordering. We write down these cliques in the order given by the elimination ordering and then draw an edge from each clique to the next clique that it intersects.Cabman
Thanks for the reply. If I take this definition, so why {3, 2} is not connected to {5, 6, 2, 0} in the correct tree decomposition (the second tree decomposition)?Graduation
@AliShakiba Ah, I can't help but keep screwing this up :(. Not the next clique that intersects, the clique generated by the seed's first neighbor that comes after the seed.Cabman
Thanks. I think this works. @DavidEisenstatGraduation

© 2022 - 2024 — McMap. All rights reserved.