Skip to content

graph relabel() assumes sortable vertices #27027

@jdemeyer

Description

@jdemeyer

There are several cases in relabel() which assume sorting of vertices.

The following cases are fixed:

  1. perm=None. This should just relabel with integers from 0 to N-1 in an arbitrary order (as the documentation already says).

  2. perm is a callable. This is easy to avoid, as the ordering of the vertices is not used in the code:

        elif callable(perm):
            perm = dict( [ i, perm(i) ] for i in self.vertices() )
            complete_partial_function = False

This broke several functions which did assume a particular ordering for G.relabel(perm=None). Those are fixed by using G.relabel(perm=range(G.order())) instead.

Furthermore, we allow arbitrary iterables to be given for relabeling instead of only list and tuple. This improves things with Python 3 where range() becomes an iterator.

CC: @dcoudert

Component: graph theory

Author: Jeroen Demeyer

Branch/Commit: a7eaec9

Reviewer: David Coudert

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions