Ask Your Question
0

bug in the pq-trees library ?

asked 2015-04-03 16:09:37 +0200

olivier gravatar image

updated 2015-04-03 16:16:57 +0200

tmonteil gravatar image

For the following PQ-tree named pqtree:

('P', [{3, 5, 7}, {4, 7}, {1, 7}, {3}, {6}, ('Q', [('P', [{0, 1, 3, 4}, {0, 6}]), {0, 2, 5}, ('P', [{2}, {2, 6}])])])

The command set_contiguous(4) gives:

sage: pqtree.set_contiguous(4)
(1, True)
sage: pqtree
('P', [{3, 5, 7}, {1, 7}, {3}, {6}, ('Q', [('P', [{2}, {2, 6}]), {0, 2, 5}, ('P', [{0, 6}, {0, 1, 3, 4}]), {4, 7}])])

Observe that the subset including 4 are not necessarily contiguous in this PQ-tree! Repeating the command gives:

sage: pqtree.set_contiguous(4)
(1, True)
sage: pqtree
('P', [{3, 5, 7}, {1, 7}, {3}, {6}, ('Q', [('P', [{2}, {2, 6}]), {0, 2, 5}, {0, 6}, {0, 1, 3, 4}, {4, 7}])])

Now it is OK, but we need to repeat twice the command.

edit retag flag offensive close merge delete

Comments

1

Could you please provide the commands to build your pq-tree?

Nathann gravatar imageNathann ( 2015-04-03 17:09:05 +0200 )edit

The initial PQ-tree is created like this :

sage: pqtree=P([[3, 5, 7],[4, 7], [1, 7], [3], [6],[0, 1, 3, 4],[0, 6], [0, 2, 5],[2], [2, 6]])

Then, if we execute the command pqtree.set_contiguous() successively on 0, 2, 4 we obtain the outcome as mentionned before.

But we obtain a good outcome with this order 2,4,0 for example.

Pegdwendé gravatar imagePegdwendé ( 2015-07-17 19:40:12 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2015-07-18 08:49:10 +0200

Nathann gravatar image

I get the following trace, in which 0,2 and 4 are contiguous.

sage: from sage.graphs.pq_trees import P
sage: pqtree=P([[3, 5, 7],[4, 7], [1, 7], [3], [6],[0, 1, 3, 4],[0, 6], [0, 2, 5],[2], [2, 6]])
sage: pqtree
('P', [{3, 5, 7}, {4, 7}, {1, 7}, {3}, {6}, {0, 1, 3, 4}, {0, 6}, {0, 2, 5}, {2}, {2, 6}])
sage: pqtree.set_contiguous(0)
(1, True)
sage: pqtree.set_contiguous(2)
(1, True)
sage: pqtree.set_contiguous(4)
(1, True)
sage: pqtree
('P', [{3, 5, 7}, {1, 7}, {3}, {6}, ('Q', [('P', [{2}, {2, 6}]), {0, 2, 5}, {0, 6}, {0, 1, 3, 4}, {4, 7}])])

Perhaps your problem can be solved by using the latest version?

edit flag offensive delete link more

Comments

Thanks, now it works with the new version !

Pegdwendé gravatar imagePegdwendé ( 2015-08-07 20:27:27 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-04-03 16:09:37 +0200

Seen: 695 times

Last updated: Jul 18 '15