# How to interpret the result of treewidth() function.

asked 2015-02-24 15:04:39 +0200

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Hi there, I want to generate a random graph and compute the optimal treewidth, also the corresponding decomposition of this graph. Here is my code in sage:

g = graphs.RandomGNM(15, 50) g.show() g.treewidth(certificate=True)

The output as follows: Graph on 7 vertices

I think this result should means in the optimal tree decomposition, there are 7 tree nodes. then my question is how can we get more detail information about which vertex of the graph belongs to which tree node of the decomposition?

Thanks for your attention!

edit retag close merge delete

Congratulations for your first question! Here are a few hints. To display code: select lines of code and click the code-formatting button (the one with "101 010"). Or indent each line of code by four spaces. Try editing your question to do that. Also, usually, don't make your question "community wiki".

( 2015-02-25 10:54:09 +0200 )edit

Sort by ยป oldest newest most voted

The nodes of the tree that you get are sets of vertices

sage: g = graphs.RandomGNM(15, 50)
sage: g.show()
sage: treedec = g.treewidth(certificate=True)
sage: treedec
Graph on 11 vertices
sage: treedec.vertices()
[{0, 3, 4, 7, 8, 9},
{0, 3, 4, 5, 7, 9, 13},
{3, 4, 5, 7, 9, 10, 13},
{0, 1, 3, 4, 6, 7, 8, 9},
{0, 2, 13, 7},
{3, 4, 5, 7, 9, 13},
{0, 2, 13, 14, 7},
{3, 5, 7, 8, 9, 13},
{3, 5, 7, 8, 9, 11, 13},
{0, 2, 3, 4, 5, 7, 9, 12},
{0, 2, 3, 4, 5, 7, 9}]

more

Got it. Thank you so much! :-)

( 2015-02-24 16:37:00 +0200 )edit