Ticket #1851: bruhat_docs_1.patch
File bruhat_docs_1.patch, 5.2 KB (added by , 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): 31 31 the construction to a neighborhood of the identity. 32 32 33 33 INPUT: 34 n  specifies which S_n 34 35 max_length  optional integer limit to length of permutations constructed 35 36 label  whether to label arcs by the transpositions they represent 36 37 37 38 """ 38 39 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 """ 39 52 cdef int i 40 53 41 54 if max_length is None: … … class BruhatSn(DiGraph): 55 68 0, label) 56 69 DiGraph.__init__(self, adj_dict) 57 70 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): 63 72 """ 64 73 Overrides the normal plot function in GenericGraph, so most arguments 65 74 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 66 89 """ 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 67 95 G = self.to_undirected() 68 return G.plot( heights=self.lengths, vertex_labels=False, vertex_size=5)96 return G.plot(**kwds) 69 97 70 98 class BruhatIntervalSn(DiGraph): 71 99 """ … … class BruhatIntervalSn(DiGraph): 81 109 """ 82 110 83 111 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 """ 84 131 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 88 132 n = len(start) 89 133 if check and n != len(end): 90 134 raise TypeError("Start (%s) and end (%s) must have same length."\ 91 135 %(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)) 92 143 93 144 a = permutation_length(start) 94 145 b = permutation_length(end) … … class BruhatIntervalSn(DiGraph): 136 187 """ 137 188 Returns True iff interval is isomorphic to its dual, the same 138 189 interval but with the order relation reversed. 190 191 EXAMPLE: 192 Note that even though the interval is ranksymmetric, it is 193 not necessarily selfdual. 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 139 200 """ 140 201 return self.is_isomorphic(self.reverse()) 141 202 … … class BruhatIntervalSn(DiGraph): 147 208 """ 148 209 Overrides the normal plot function in GenericGraph, so most arguments 149 210 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 150 217 """ 151 218 G = self.to_undirected() 152 219 return G.plot(heights=self.lengths, vertex_labels=False,