Home > matgraph > @permutation > longest_cycle.m

longest_cycle

PURPOSE ^

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: 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

Generated on Thu 13-Mar-2008 14:23:52 by m2html © 2003