#19517: Graphs: canonical_label() and return_graph -parameter
--------------------------------+-------------------------
Reporter: jmantysalo | Owner:
Type: defect | Status: new
Priority: major | Milestone: sage-6.10
Component: graph theory | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
--------------------------------+-------------------------
Old description:
> Several problems I noticed on `generic_graph.py`:
>
> - Indentation in docstring for `return_graph` is wrong.
>
> - That parameter seems to have no effect when `algorithm='sage'`:
>
> {{{
> sage: G = Graph({10: [20]})
> sage: G.canonical_label(algorithm='sage', return_graph=False)
> Graph on 2 vertices
> sage: G.vertices()
> [10, 20]
> sage: G.canonical_label(algorithm='sage', return_graph=True)
> Graph on 2 vertices
> sage: G.vertices()
> [10, 20]
> }}}
>
> - I installed bliss with `sage -i` and it seems to be fine. I got normal
> messages from gcc and then `Successfully installed bliss-0.73`, and
> `'bliss' in sage.misc.package.optional_packages()[0]` says `True`. But
> still
>
> {{{
> sage: G.canonical_label(algorithm='bliss', return_graph=True)
> ---------------------------------------------------------------------------
> ImportError Traceback (most recent call
> last)
> . . .
> ImportError: You must install the 'bliss' package to run this command.
> }}}
>
> - Why the name of the parameter `return_graph` in this, but `inplace` in
> all other functions?
New description:
On `generic_graph.py` function `canonical_label()` parameter
`return_graph`:
- The parameter has no effect when `algorithm='sage'`:
{{{
sage: G = Graph({10: [20]})
sage: G.canonical_label(algorithm='sage', return_graph=False)
Graph on 2 vertices
sage: G.canonical_label(algorithm='sage', return_graph=True)
Graph on 2 vertices
}}}
compared to
{{{
sage: G.canonical_label(algorithm='bliss', return_graph=False)
[(1, 0)]
sage: G.canonical_label(algorithm='bliss', return_graph=True)
Graph on 2 vertices
}}}
- Docstring is badly formulated. It should say that it returns list of
edges of canonically labelled graph.
- Indentation in docstring is wrong.
- (And is it meaningful? Why not return dictionary of vertex relabeling
instead of edges?)
Same function has other problem:
- Canonically relabeled graph forgets vertex positioning. This is contrary
to `relabel` that remembers them. This can be seen with
{{{
P = graphs.PetersenGraph()
P1 = graphs.PetersenGraph()
P1.relabel(lambda x: chr(ord('a')+x))
P2 = P1.canonical_label()
P.show()
P1.show()
P2.show()
}}}
--
Comment (by jmantysalo):
OK, modified the description. I do not think that forgetting vertex
positions is necessarily a bug. But to remember them on `relabel()` and to
forget on `canonical_label()` is.
--
Ticket URL: <http://trac.sagemath.org/ticket/19517#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.