Home > matgraph > @permutation > display.m

display

PURPOSE ^

display(p) --- display a permutation in disjoint cycle form.

SYNOPSIS ^

function st = display(p)

DESCRIPTION ^

 display(p) --- display a permutation in disjoint cycle form.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function st = display(p)
0002 % display(p) --- display a permutation in disjoint cycle form.
0003 
0004 
0005 % special case if the permutation is empty
0006 if isempty(p)
0007     st= '()';
0008     if nargout == 0
0009         disp(st)
0010     end
0011     return
0012 end
0013 
0014 c = cycles(p);
0015 outstr = '';
0016 
0017 for k=1:length(c)
0018     outstr = [outstr,list_to_cycle(c{k})];
0019 end
0020 
0021 
0022 if nargout > 0
0023     st = outstr;
0024 else
0025     disp(outstr)
0026 end
0027 
0028 
0029 function str = list_to_cycle(list)
0030 if isempty(list) 
0031     str = '()';
0032     return
0033 end
0034 
0035 str = '(';
0036 for k=1:length(list)
0037     str = [str,int2str(list(k))];
0038     if k < length(list)
0039         str = [str,','];
0040     else
0041         str = [str,')'];
0042     end
0043 end

Generated on Fri 05-Feb-2010 13:55:18 by m2html © 2003