Ticket #14000: trac_14000-doctests.patch

File trac_14000-doctests.patch, 2.0 KB (added by ncohen, 7 years ago)
  • sage/graphs/generic_graph.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1361572641 -3600
    # Node ID 1460b5f0f6ecafd0199dfa1d443054fd01a8ceac
    # Parent  d7b6a30e6acc9f2443b027d8836bb37ee5646919
    Speedup in GenericGraph.relabel() and two new options -- new doctests
    
    diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
    a b  
    1571115711            [1 0 1]
    1571215712            [0 1 0]
    1571315713
    15714         Relabeling using a dictionary::
     15714        Relabeling using a dictionary. Note that the dictionary does not define
     15715        the new label of vertex `0`::
    1571515716
    1571615717            sage: G.relabel({1:2,2:1}, inplace=False).am()
    1571715718            [0 0 1]
    1571815719            [0 0 1]
    1571915720            [1 1 0]
    1572015721
     15722        This is because the method automatically "extends" the relabeling to the
     15723        missing vertices (whose label will not change). Checking that all
     15724        vertices have an image can require some time, and this feature can be
     15725        disabled (at your own risk)::
     15726
     15727            sage: G.relabel({1:2,2:1}, inplace=False, complete_partial_function = False).am()
     15728            Traceback (most recent call last):
     15729            ...
     15730            KeyError: 0
     15731
    1572115732        Relabeling using a list::
    1572215733
    1572315734            sage: G.relabel([0,2,1], inplace=False).am()
     
    1575215763            sage: H.edges()
    1575315764            [(10, 11, None), (11, 12, None)]
    1575415765
    15755         Relabeling using a non injective function is not yet supported::
     15766        Relabeling using a non injective function has no meaning::
    1575615767
    1575715768            sage: G.edges()
    1575815769            [(0, 1, None), (1, 2, None)]
     
    1576115772            ...
    1576215773            NotImplementedError: Non injective relabeling
    1576315774
     15775        But this test can be disabled, which leads to ... problems::
     15776
     15777            sage: G.edges()
     15778            [(0, 1, None), (1, 2, None)]
     15779            sage: G.relabel(lambda i: 0, check_input = False)
     15780            sage: G.edges()
     15781            [(0, 0, None)]
     15782
    1576415783        Relabeling to simpler labels::
    1576515784
    1576615785            sage: G = graphs.CubeGraph(3)