Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Barycentric embedding for planar graphs. #9699

Open
sagetrac-fidelbarrera mannequin opened this issue Aug 6, 2010 · 25 comments
Open

Barycentric embedding for planar graphs. #9699

sagetrac-fidelbarrera mannequin opened this issue Aug 6, 2010 · 25 comments

Comments

@sagetrac-fidelbarrera
Copy link
Mannequin

sagetrac-fidelbarrera mannequin commented Aug 6, 2010

Positions of vertices returned by planar_layout can be set to have the vertices of an equilateral triangle as exterior vertices.

Apply only attachment: trac_9699_4.patch

CC: @rlmill @boothby

Component: graph theory

Author: Fidel Barrera-Cruz

Reviewer: Nathann Cohen, Robert Miller

Issue created by migration from https://trac.sagemath.org/ticket/9699

@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Aug 7, 2010

Attachment: trac_9699.patch.gz

Updated patch, it includes an example.

@rlmill
Copy link
Mannequin

rlmill mannequin commented Aug 7, 2010

comment:3

I wonder if the default for barycentric shouldn't be True instead of False. It looks a bit nicer that way, so why not make it the default?

@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Aug 8, 2010

Attachment: trac_9699_2.patch.gz

Please apply instead of trac_9699.patch.

@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Aug 8, 2010

comment:4

Replying to @rlmill:

I wonder if the default for barycentric shouldn't be True instead of False. It looks a bit nicer that way, so why not make it the default?

The option barycentric is now set to True by default.

@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Aug 8, 2010

comment:5

Replying to @rlmill:

I wonder if the default for barycentric shouldn't be True instead of False. It looks a bit nicer that way, so why not make it the default?

Sorry, I forgot to be more specific. Please apply trac_9699_2.patch instead of trac_9699.patch.

In trac_9699_2.patch the option barycentric is now set to be True by default.

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Sep 5, 2010

comment:6

Well, if such an option is the default, shouldn't we just replace the actual code with it ? As these barycentric coordinates are as valid as the previous ones in the general case, I except the code used by barycentric = False never to be used again... :-p

What about just replacing the current code to compute barycentric coordinates, and add this information as notes in the documentation ?

Nathann

@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Sep 13, 2010

comment:7

Replying to @nathanncohen:

Well, if such an option is the default, shouldn't we just replace the actual code with it ?

I think the previous implementation features interesting properties. It provided a straightline embedding in an O(n) by O(n) grid, so in particular all the coordinates are integers. Would you still suggest to replace the code completely?

Fidel

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Sep 13, 2010

comment:8

I think the previous implementation features interesting properties. It provided a straightline embedding in an O(n) by O(n) grid, so in particular all the coordinates are integers. Would you still suggest to replace the code completely?

No, not anymore... But now I would suggest to mention these properties in the docstring. Sorry for asking it this late, but I am concerned about avoiding to have in Sage at the same time two pieces of code doing the same thing in different ways, and writing it in such a way that one of them is never used.. That's why I wondered whether it would be better to completely replace the current implementation with yours instead of having two version. If the current version has properties that yours do not have, then you are right : it should remain available, but this is not very useful if nobody knows these properties exists.... Hence, where you documented the keyword barycentric

- ``barycentric`` - whether or not to use barycentric coordinates. 

it would be nice to also mention that setting it to None means having an embedding in a O(n)*O(n) grid with integer coordinates, as you just taught me.. Otherwise it's very unlikely people would disable a feature with no computation time to earn...nothing :-)

Nathann

@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Sep 22, 2010

Please apply instead of previous patches.

@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Sep 22, 2010

comment:9

Attachment: trac_9699_3.patch.gz

Replying to @nathanncohen:

But now I would suggest to mention these properties in the docstring.

These properties are now mentioned in the docstring :)

Fidel

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Sep 22, 2010

comment:10

Hello !!

I noticed a typo in your patch

then coordinates will bi in the grid. 

So I first wrote a small one to fix it, then ended up fixing one or two other docstrings, or adding to them the information you had put in the first description or barycentric.. Well, if somebody can test my patch, he can set this ticket to "positive review", as yours is good to go !

Thanksssssssssssssss ! :-)

Nathann

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Sep 22, 2010

Attachment: trac_9699 - docstring fixes.patch.gz

@rlmill
Copy link
Mannequin

rlmill mannequin commented Nov 11, 2010

comment:11

Doctest fail:

sage -t -long ./sage/graphs/generic_graph.py
**********************************************************************
File "/home/rlmill/sage-4.6/devel/sage-main/sage/graphs/generic_graph.py", line 2620:
    sage: g.layout(layout = "planar", save_pos = True)
Expected:
    {0: [1, 1], 1: [2, 2], 2: [3, 2], 3: [1, 4], 4: [5, 1], 5: [0, 5], 6: [1, 0]}
Got:
    {0: (-0.433012701892, -0.25), 1: (1.11022302463e-16, -7.40148683083e-17), 2: (0.144337567297, 0.25), 3: (0.433012701892, -0.25), 4: [0.0, 1.0], 5: [0.866025403784, -0.5], 6: [-0.866025403784, -0.5]}
**********************************************************************

Also, all of the positions should be the same format: here some are tuples and others are lists.

@rlmill
Copy link
Mannequin

rlmill mannequin commented Nov 11, 2010

Reviewer: Nathann Cohen, Robert Miller

@rlmill rlmill mannequin added s: needs work and removed s: needs review labels Nov 11, 2010
@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Nov 21, 2010

Attachment: trac_9699_4.patch.gz

Please apply instead of previous patches.

@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Nov 21, 2010

comment:12

Hello,

The patch file trac_9699_4.patch includes a fix to the doctest fail. It also includes a fix to the problem having tuples and lists for the positions. Now, all of the positions are lists.

Fidel

@rlmill rlmill mannequin added the s: positive review label Nov 26, 2010
@jdemeyer jdemeyer modified the milestones: sage-4.6.1, sage-4.6.2 Nov 26, 2010
@jdemeyer
Copy link

comment:15

Has this been tested on various systems? The kind of output like

{0: [0.0, 1.0], 1: [0.866025403784, -0.5], 2: [-0.866025403784, -0.5], 3: [0.433012701892, -0.25], 4: [-0.288675134595, -1.85037170771e-16], 5: [0.288675134595, 3.70074341542e-17], 6: [0.144337567297, 0.25]}

has a tendency of being quite system-dependent because of precision issues.

In any case, if all you did was add an option, why did the output change?

@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Nov 26, 2010

comment:16

Replying to @jdemeyer:

Has this been tested on various systems?

I have not tested it on various systems.

In any case, if all you did was add an option, why did the output change?

The option barycentric was no just added, it was made the default option, as suggested by rlm in

#9699

@rlmill
Copy link
Mannequin

rlmill mannequin commented Nov 26, 2010

comment:17

Replying to @jdemeyer:

{0: [0.0, 1.0], 1: [0.866025403784, -0.5], 2: [-0.866025403784, -0.5], 3: [0.433012701892, -0.25], 4: [-0.288675134595, -1.85037170771e-16], 5: [0.288675134595, 3.70074341542e-17], 6: [0.144337567297, 0.25]}

Jeroen is right. You should replace things like 0.866025403784 with 0.86... so that numerical issues don't crop up.

@rlmill rlmill mannequin added s: needs work and removed s: needs info labels Nov 26, 2010
@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Nov 27, 2010

Attachment: trac_9699_5.patch.gz

Please apply instead of previous patches.

@sagetrac-fidelbarrera
Copy link
Mannequin Author

sagetrac-fidelbarrera mannequin commented Nov 27, 2010

comment:18

Replying to @rlmill:

Jeroen is right. You should replace things like 0.866025403784 with 0.86... so that numerical issues don't crop up.

Replaced things like 0.866025403784 with 0.86....

Please see trac_9699_5.patch instead of previous versions.

@rlmill
Copy link
Mannequin

rlmill mannequin commented Nov 28, 2010

comment:19

Okay, I tested all long doctests on a 64 bit Linux machine, and all passed. I also tested long doctests in sage/graphs on a 32 bit Linux machine, and again all tests pass. Things look good.

@rlmill
Copy link
Mannequin

rlmill mannequin commented Nov 28, 2010

comment:20

It seems I pressed submit too soon. Indeed all tests pass on the 64 bit system.

However on the 32-bit system, things seem to freeze at the following test:

Trying:
    g = graphs.BalancedTree(Integer(3),Integer(4))###line 2658:_sage_    >>> g = graphs.BalancedTree(3,4)
Expecting nothing
ok
Trying:
    g.set_planar_positions(test=True)###line 2659:_sage_    >>> g.set_planar_positions(test=True)
Expecting:
    True

@rlmill rlmill mannequin added s: needs work and removed s: positive review labels Nov 28, 2010
@rlmill
Copy link
Mannequin

rlmill mannequin commented Nov 28, 2010

comment:21

Ugh. Once again I spoke too soon.

The real problem is just that the doctests take much longer after the patch than before.

On the 32 bit system it went from 243.2 s for generic_graph.py up to 623.8 s after the patch.

On the (much faster) 64 bit system it was 130.4 s before and 441.2 s after.

This definitely counts as a regression, and I can't let things through with so much of a slowdown.

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@mkoeppe mkoeppe removed this from the sage-6.4 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants