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

equality testing in graphs should check "weighted" property #5003

Closed
rlmill mannequin opened this issue Jan 17, 2009 · 6 comments
Closed

equality testing in graphs should check "weighted" property #5003

rlmill mannequin opened this issue Jan 17, 2009 · 6 comments

Comments

@rlmill
Copy link
Mannequin

rlmill mannequin commented Jan 17, 2009

See:

http://groups.google.com/group/sage-support/browse_thread/thread/d01dd8082da28d52?hl=en

Component: graph theory

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

@rlmill rlmill mannequin added this to the sage-3.3 milestone Jan 17, 2009
@rlmill rlmill mannequin added c: graph theory labels Jan 17, 2009
@rlmill rlmill mannequin self-assigned this Jan 17, 2009
@rlmill rlmill mannequin added the s: needs review label Jan 17, 2009
@rlmill
Copy link
Mannequin Author

rlmill mannequin commented Jan 17, 2009

Attachment: trac-5003_weighted_eq_graphs.patch.gz

@shumow
Copy link

shumow commented Jan 24, 2009

comment:1

Hey, I ran into some doctest failures w/ your new change.

Specifically, around line 839 (in the docstring for weighted_ajacency_matrix(...)):

        EXAMPLES:
            sage: G = Graph(sparse=True)
            sage: G.add_edges([(0,1,1),(1,2,2),(0,2,3),(0,3,4)])
            sage: M = G.weighted_adjacency_matrix(); M
            [0 1 3 4]
            [1 0 2 0]
            [3 2 0 0]
            [4 0 0 0]
            sage: H = Graph(data=M, format='weighted_adjacency_matrix', sparse=True)
            sage: H == G
            True

This fails. Specifically, G.weighted() returns false (which seems like its own bug.)

And Also, the example starting at line 1180 (in the docstring for weighted(...):

        EXAMPLE:
        Here we have two graphs with different labels, but weighted is False
        for both, so we just check for the presence of edges:
            sage: G = Graph({0:{1:'a'}}, implementation='networkx')
            sage: H = Graph({0:{1:'b'}}, implementation='networkx')
            sage: G == H
            True

        Now one is weighted and the other is not, so the comparison is done as
        if neither is weighted:
            sage: G.weighted(True)
            sage: H.weighted()
            False
            sage: G == H
            True

Fails. Because of the change.

The first of these issues, is a bug and should be fixed IMHO. The second issue is more subtle and disturbing. Particularly because it indicates that a valid example used to work, you will be breaking compatibility with code that works this way, and you should think about what the previous assumptions were, and if you can work around them with a fix.

@rlmill
Copy link
Mannequin Author

rlmill mannequin commented Jan 24, 2009

comment:2

Replying to @shumow:

This fails. Specifically, G.weighted() returns false (which seems like its own bug.)

Not so much a bug, as a typo in the doctest. If you don't say G is weighted, then just adding edges with weights shouldn't change that. In fact, that's the point of the other doctest.

And Also, the example starting at line 1180 (in the docstring for weighted(...):

...

Fails. Because of the change.

The second issue is more subtle and disturbing. Particularly because it indicates that a valid example used to work, you will be breaking compatibility with code that works this way, and you should think about what the previous assumptions were, and if you can work around them with a fix.

Well, it's more like we're updating things to actually do it correctly. Before, weighted wasn't a property of graphs, and that test was kind of a warning about that. I don't know of any code that would be affected by this, but I think this is the right way to do things.

@rlmill rlmill mannequin added s: needs review and removed s: needs work labels Jan 24, 2009
@rlmill
Copy link
Mannequin Author

rlmill mannequin commented Jan 24, 2009

Apply this patch second.

@mwhansen
Copy link
Contributor

comment:3

Attachment: trac-5003-followup.patch.gz

Looks good to me.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Jan 24, 2009

comment:4

Merged in Sage 3.3.alpha2.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Jan 24, 2009
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

2 participants