sort_loop_index

PURPOSE ^

SORT_LOOP_INDEX Sort the loop indices such that the smallest index comes

SYNOPSIS ^

function[loop_list_sorted]=sort_loop_index(loop_list)

DESCRIPTION ^

SORT_LOOP_INDEX Sort the loop indices such that the smallest index comes
first.

 LOOP_LIST_SORTED=SORT_LOOP_INDEX(LOOP_LIST)
 The input LOOP_LIST has the form of the output of functions from the LoopDetect
 function suite, or at least one column named "loop" that contains a cell
 array with each entry capturing the order of the node indices (integer values) forming the loop.

Example
   J = [-1 0 0 -1; 1 -1 0 1; 0 1 -1 0; 0 0 1 -1];
   loop_t = find_loops(J);
   loop_t.loop{1}
   loop_t_sorted=sort_loop_index(loop_t);
   loop_t_sorted.loop{1}
 
 See also FIND_LOOPS, FIND_LOOPS_NOSCC, FIND_LOOPS_VSET

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function[loop_list_sorted]=sort_loop_index(loop_list)
0002 %SORT_LOOP_INDEX Sort the loop indices such that the smallest index comes
0003 %first.
0004 %
0005 % LOOP_LIST_SORTED=SORT_LOOP_INDEX(LOOP_LIST)
0006 % The input LOOP_LIST has the form of the output of functions from the LoopDetect
0007 % function suite, or at least one column named "loop" that contains a cell
0008 % array with each entry capturing the order of the node indices (integer values) forming the loop.
0009 %
0010 %Example
0011 %   J = [-1 0 0 -1; 1 -1 0 1; 0 1 -1 0; 0 0 1 -1];
0012 %   loop_t = find_loops(J);
0013 %   loop_t.loop{1}
0014 %   loop_t_sorted=sort_loop_index(loop_t);
0015 %   loop_t_sorted.loop{1}
0016 %
0017 % See also FIND_LOOPS, FIND_LOOPS_NOSCC, FIND_LOOPS_VSET
0018 
0019 function[outvec]=sort_vector(inputvec)
0020     [a,b]=min(inputvec);
0021     outvec=[inputvec(b:end),inputvec(2:b)];
0022 end
0023 
0024 loop_list_sorted_loops=cellfun(@sort_vector,loop_list.loop,'UniformOutput',false);
0025 
0026 loop_list_sorted=loop_list;
0027 %replace the loop lists by sorted loop lists
0028 loop_list_sorted.loop=loop_list_sorted_loops;
0029 end
0030

Generated on Wed 24-Jun-2020 09:38:33 by m2html © 2005