Ticket #1851: bruhat_docs_1.patch

File bruhat_docs_1.patch, 5.2 KB (added by rlm, 12 years ago)
  • sage/graphs/bruhat_sn.pyx

    # HG changeset patch
    # User Robert L. Miller <rlm@rlmiller.org>
    # Date 1200775427 28800
    # Node ID 9708f6bb033bfb0dd3b5138c144539eb2fb09eca
    # Parent  91998f13b187fc782b1f2ec71ecf8005a9c5f825
    documentation in bruhat_sn.pyx
    
    diff -r 91998f13b187 -r 9708f6bb033b sage/graphs/bruhat_sn.pyx
    a b class BruhatSn(DiGraph): 
    3131    the construction to a neighborhood of the identity.
    3232   
    3333    INPUT:
     34        n -- specifies which S_n
    3435        max_length -- optional integer limit to length of permutations constructed
    3536        label -- whether to label arcs by the transpositions they represent
    3637
    3738    """
    3839    def __init__(self, int n, max_length=None, label=False):
     40        """
     41        TESTS:
     42            sage: from sage.graphs.bruhat_sn import *
     43            sage: B = BruhatSn(6)
     44            sage: B.order()
     45            720
     46            sage: B = BruhatSn(6, max_length=4, label=True)
     47            sage: B.order()
     48            98
     49            sage: B.plot(edge_labels=True)
     50
     51        """
    3952        cdef int i
    4053
    4154        if max_length is None:
    class BruhatSn(DiGraph): 
    5568                  0, label)
    5669        DiGraph.__init__(self, adj_dict)
    5770   
    58     def plot(self, pos=None, layout=None, vertex_labels=True,
    59              edge_labels=False, vertex_size=200, graph_border=False,
    60              vertex_colors=None, partition=None, edge_colors=None,
    61              scaling_term=0.05, iterations=50,
    62              color_by_label=False, heights=None):
     71    def plot(self, **kwds):
    6372        """
    6473        Overrides the normal plot function in GenericGraph, so most arguments
    6574        are ignored.
     75       
     76        INPUT:
     77            All the standard arguments for GenericGraph.plot() are taken, but
     78            heights is definitely overridden to reflect the partial ordering.
     79            Also, arcs are plotted as edges.
     80
     81        EXAMPLES:
     82            sage: from sage.graphs.bruhat_sn import *
     83            sage: B = BruhatSn(3, label=True)
     84            sage: B.plot(edge_labels=True)
     85
     86            sage: B = BruhatSn(5, max_length=7)
     87            sage: B.plot()
     88
    6689        """
     90        kwds['heights'] = self.lengths
     91        if not kwds.has_key('vertex_labels'):
     92            kwds['vertex_labels'] = False
     93        if not kwds.has_key('vertex_size'):
     94            kwds['vertex_size'] = 5
    6795        G = self.to_undirected()
    68         return G.plot(heights=self.lengths, vertex_labels=False, vertex_size=5)
     96        return G.plot(**kwds)
    6997
    7098class BruhatIntervalSn(DiGraph):
    7199    """
    class BruhatIntervalSn(DiGraph): 
    81109    """
    82110   
    83111    def __init__(self, start, end, check=True, label=False):
     112        """
     113        TESTS:
     114            sage: from sage.graphs.bruhat_sn import *
     115            sage: I = BruhatIntervalSn([1,2,3], [3,2,1])
     116            Traceback (most recent call last):
     117            ...
     118            TypeError: Start ([1, 2, 3]) and end ([3, 2, 1]) must be tuples.
     119
     120            sage: I = BruhatIntervalSn((1,2,3,4), (3,2,1))
     121            Traceback (most recent call last):
     122            ...
     123            TypeError: Start ((1, 2, 3, 4)) and end ((3, 2, 1)) must have same length.
     124
     125            sage: I = BruhatIntervalSn((3,2,1),(1,2,3))
     126            Traceback (most recent call last):
     127            ...
     128            TypeError: Must have start ((3, 2, 1)) <= end ((1, 2, 3))
     129
     130        """
    84131        cdef int a, b, n, i, j
    85         if check and not leq(start, end):
    86                 raise TypeError("Must have start (%s) <= end (%s)"%(start, end))
    87        
    88132        n = len(start)
    89133        if check and n != len(end):
    90134            raise TypeError("Start (%s) and end (%s) must have same length."\
    91135                            %(start, end))
     136       
     137        if check and not (isinstance(start,tuple) and isinstance(end,tuple)):
     138            raise TypeError("Start (%s) and end (%s) must be tuples."\
     139                            %(start, end))
     140       
     141        if check and not leq(start, end):
     142                raise TypeError("Must have start (%s) <= end (%s)"%(start, end))
    92143       
    93144        a = permutation_length(start)
    94145        b = permutation_length(end)
    class BruhatIntervalSn(DiGraph): 
    136187        """
    137188        Returns True iff interval is isomorphic to its dual, the same
    138189        interval but with the order relation reversed.
     190
     191        EXAMPLE:
     192        Note that even though the interval is rank-symmetric, it is
     193        not necessarily self-dual.
     194            sage: from sage.graphs.bruhat_sn import *
     195            sage: I = BruhatIntervalSn((1,3,2,4,5),(3,5,1,4,2))
     196            sage: I.is_self_dual()
     197            False
     198            sage: I.plot()
     199
    139200        """
    140201        return self.is_isomorphic(self.reverse())
    141202   
    class BruhatIntervalSn(DiGraph): 
    147208        """
    148209        Overrides the normal plot function in GenericGraph, so most arguments
    149210        are ignored.
     211
     212        EXAMPLE:
     213            sage: from sage.graphs.bruhat_sn import *
     214            sage: I = BruhatIntervalSn((1,3,2,4,5),(3,5,1,4,2))
     215            sage: I.plot()
     216
    150217        """
    151218        G = self.to_undirected()
    152219        return G.plot(heights=self.lengths, vertex_labels=False,