compare_loop_list

PURPOSE ^

COMPARE_LOOP_LIST Compare two lists of loops.

SYNOPSIS ^

function[ind_a_id,ind_a_switch,ind_a_notin,ind_b_id,ind_b_switch]=compare_loop_list(loop_list_a,loop_list_b)

DESCRIPTION ^

 COMPARE_LOOP_LIST Compare two lists of loops. 

 COMPARE_LOOP_LIST analyzes which loops in loop_list_a are shared between both lists, have 
 switched sign or do not occur in loop_list_b. Loop lists should be outputs of
 functions such as find_loops(), find_loops_noscc(), find_loops_vset(). 
 Internally, the function performs sorting of the loops (relying on sort_loop_index) in
 order to enable comparison.

 IND_A_ID = COMPARE_LOOP_LIST(LOOP_LIST_A,LOOP_LIST_B) returns the indices
 of loops in LOOP_LIST_A that are also in LOOP_LIST_B (same loop and same
 sign).

 [IND_A_ID,IND_A_SWITCH,IND_A_NOTIN] = COMPARE_LOOP_LIST(LOOP_LIST_A,LOOP_LIST_B)
 returns in addition the indices of loops in LOOP_LIST_A that occur in
 LOOP_LIST_B but with switched sign (positive feedback loop instead of
 negative feedback loop or vice versa), and the indices of the loops that
 do not occur in LOOP_LIST_B

 [IND_A_ID,IND_A_SWITCH,IND_A_NOTIN,IND_B_ID,IND_B_SWITCH] = COMPARE_LOOP_LIST(LOOP_LIST_A,LOOP_LIST_B)
 returns also the indices of the loops in LOOP_LIST_B, IND_B_ID, corresponding to the
 loops in LOOP_LIST_B given by IND_A_ID, as well as the indices of the loops in LOOP_LIST_B,
 IND_B_SWITCH, that correspond to the
 loops in LOOP_LIST_B given by IND_A_SWITCH. Thus, LOOP_LIST_A(IND_A_ID,:) is exactly
 identical to LOOP_LIST_B(IND_B_ID,:) (also in the same order), up to
 changes in with which node index is started in the description of the
 loops. LOOP_LIST_A(IND_A_SWITCH,:) differs from
 LOOP_LIST_B(IND_B_SWITCH,:) only in the 'sign' column (and possibly in
 the first reported node index of loops).

 See also: FIND_LOOPS, FIND_LOOPS_NOSCC, FIND_LOOPS_VSET, SORT_LOOP_INDEX

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function[ind_a_id,ind_a_switch,ind_a_notin,ind_b_id,ind_b_switch]=compare_loop_list(loop_list_a,loop_list_b)
0002 % COMPARE_LOOP_LIST Compare two lists of loops.
0003 %
0004 % COMPARE_LOOP_LIST analyzes which loops in loop_list_a are shared between both lists, have
0005 % switched sign or do not occur in loop_list_b. Loop lists should be outputs of
0006 % functions such as find_loops(), find_loops_noscc(), find_loops_vset().
0007 % Internally, the function performs sorting of the loops (relying on sort_loop_index) in
0008 % order to enable comparison.
0009 %
0010 % IND_A_ID = COMPARE_LOOP_LIST(LOOP_LIST_A,LOOP_LIST_B) returns the indices
0011 % of loops in LOOP_LIST_A that are also in LOOP_LIST_B (same loop and same
0012 % sign).
0013 %
0014 % [IND_A_ID,IND_A_SWITCH,IND_A_NOTIN] = COMPARE_LOOP_LIST(LOOP_LIST_A,LOOP_LIST_B)
0015 % returns in addition the indices of loops in LOOP_LIST_A that occur in
0016 % LOOP_LIST_B but with switched sign (positive feedback loop instead of
0017 % negative feedback loop or vice versa), and the indices of the loops that
0018 % do not occur in LOOP_LIST_B
0019 %
0020 % [IND_A_ID,IND_A_SWITCH,IND_A_NOTIN,IND_B_ID,IND_B_SWITCH] = COMPARE_LOOP_LIST(LOOP_LIST_A,LOOP_LIST_B)
0021 % returns also the indices of the loops in LOOP_LIST_B, IND_B_ID, corresponding to the
0022 % loops in LOOP_LIST_B given by IND_A_ID, as well as the indices of the loops in LOOP_LIST_B,
0023 % IND_B_SWITCH, that correspond to the
0024 % loops in LOOP_LIST_B given by IND_A_SWITCH. Thus, LOOP_LIST_A(IND_A_ID,:) is exactly
0025 % identical to LOOP_LIST_B(IND_B_ID,:) (also in the same order), up to
0026 % changes in with which node index is started in the description of the
0027 % loops. LOOP_LIST_A(IND_A_SWITCH,:) differs from
0028 % LOOP_LIST_B(IND_B_SWITCH,:) only in the 'sign' column (and possibly in
0029 % the first reported node index of loops).
0030 %
0031 % See also: FIND_LOOPS, FIND_LOOPS_NOSCC, FIND_LOOPS_VSET, SORT_LOOP_INDEX
0032 
0033 % Examples
0034 % length(ind_a_id)==height(loop_list_a) means all loops from list a are
0035 % also in list b
0036 % loop_list_a(ind_a_id(2),:) is the same loop as loop_list_b(ind_b_id(2),:)
0037 %
0038 
0039 
0040 
0041 function[loop_list_sorted]=sort_loop_index(loop_list)
0042    %sort the loop indices to start with lowest index in all loops
0043     function[outvec]=sort_vector(inputvec)
0044         [a,b]=min(inputvec);
0045         outvec=[inputvec(b:end),inputvec(2:b)];
0046     end
0047 
0048     loop_list_sorted_loops=cellfun(@sort_vector,loop_list.loop,'UniformOutput',false);
0049 
0050     loop_list_sorted=loop_list;
0051     %replace the loop lists by sorted loop lists
0052     loop_list_sorted.loop=loop_list_sorted_loops;
0053 end
0054 
0055 %first: sort the loops in both lists for starting with the lowest index.
0056 loop_list_a_sorted=sort_loop_index(loop_list_a);
0057 loop_list_b_sorted=sort_loop_index(loop_list_b);
0058 
0059 %check for each loop in loop_list1 whether there is a loop in loop_list2
0060 %such that the loops are identical (maybe different sign)
0061 is_in_index=cellfun(@(a) find(cellfun(@(z) isequal(a,z), loop_list_b_sorted.loop)),loop_list_a_sorted.loop,'UniformOutput',false);
0062 
0063 %indices of these loops in list 1
0064 indices_in_a=find(cellfun('length',is_in_index)==1);
0065 %indices of these loops in list 2
0066 indices_in_b=cell2mat(is_in_index(cellfun('length',is_in_index)==1));
0067 
0068 %which of the loops have the same sign
0069 ind_a_id=indices_in_a(loop_list_a.sign(indices_in_a)==...
0070     loop_list_b.sign(indices_in_b));
0071 ind_b_id=indices_in_b(loop_list_a.sign(indices_in_a)==...
0072     loop_list_b.sign(indices_in_b));
0073 
0074 %which of the loops have switching signs
0075 ind_a_switch=indices_in_a(not(loop_list_a.sign(indices_in_a)==...
0076     loop_list_b.sign(indices_in_b)));
0077 ind_b_switch=indices_in_b(not(loop_list_a.sign(indices_in_a)==...
0078     loop_list_b.sign(indices_in_b)));
0079 
0080 %indices of loops in list a that do not occur in list b
0081 ind_a_notin = find(cellfun('length',is_in_index)==0);
0082 
0083 end

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