Hello !!

Using 
>    G.relabel( [ i+1 for i in range(G.order()) ], inplace=True )
> and repeat the same command once more causes the error below.
>

That is because of that (rom the doc of Graph.relabel) :

        If ``perm`` is a dictionary ``d``, then each vertex ``v``
        (which should be a key of ``d``) is relabeled to ``d[v]``.
        Similarly, if ``perm`` is a list or tuple ``l`` of length
        ``n``, then each vertex (which should be in `\{0,1,...,n-1\}`)
        is relabeled to ``l[v]`

I agree that the error message is not clear, though.

The reason is the following : If your vertices are named 
"a","r","whatever","hello" and you want to relabel them with "1,2,3,4" then 
there is no way to know which vertex is theone that should be renamed to 1, 
which to 2, etc ... If your vertex set is 0,1,2,3 ... to begin with,  then 
we "can assume" that you want vertex 0 to be renamed to the first vertex of 
your list, vertex 1 to the second, etc ...

When you use the second syntax :
 

> But using 
>    G.relabel(lambda i: i+1, inplace=True)
> twice does not produce the error.
>

there is no such doubt, and we know which vertex should be renamed to which 
output by applying the lambda function.

I think we should change the code above, so that when you feed .relabel() 
with a list then the "first vertex of g.vertices()" is labeled with the 
"first vertex of your list", etc, etc ... I hope that it will not create 
any confusion that I do not see at the moment.

Nathann

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" 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-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to