longest_cycle(p) -- return the length of the longest cycle in p
SYNOPSIS
function maxlen = longest_cycle(p)
DESCRIPTION
longest_cycle(p) -- return the length of the longest cycle in p
where p is a permutation
CROSS-REFERENCE INFORMATION
This function calls:
cycles cycles(p) returns a cell array containing the cycle structure of p
length length(p) gives the size of the permutation
This function is called by:
SOURCE CODE
0001 function maxlen = longest_cycle(p)
0002 % longest_cycle(p) -- return the length of the longest cycle in p
0003 % where p is a permutation
0004
0005 clist = cycles(p);
0006 maxlen = 0;
0007 for k=1:length(clist)
0008 len = length(clist{k});
0009 if (len > maxlen)
0010 maxlen = len;
0011 end
0012 end