Home > matpower6.0 > extras > reduction > SelfLink.m

SelfLink

PURPOSE ^

FUNCTION SUMMARY:

SYNOPSIS ^

function [LinkPos,LinkArray,Counter] = SelfLink(Link,Start)

DESCRIPTION ^

 FUNCTION SUMMARY:
   Subroutine SelfLink search the Link array in by self referencing. The
   searching process will stop until a zero is found. Every non-zero
   element found in the searching process will be stored in LinkArray and
   their corresponding index pointers will be stored in LinkPos. Couter
   will count the number of numzero element in LinkArray.

   [LinkPos,LinkArray,Counter] = SelfLink(Link,Start)

 INPUT DATA:
   Link - N * 1 array containing the link list
   Start- scalar is the starting point of the searching process

 OUTPUT DATA:
   Counter - scalar, number of non-zero elements in LinkArray
   LinkArray - N*1 array, containing the non-zero element found in the searching
       process
   LinkPos - N*1 array, containing the index pointers of the non-zero
       elements stored in LinkArray

 INTERNAL DATA:
   SelRef - scalar, used to do searching in Link list, which is equal to
       the current found element and also pointer to the next element

 NOTE:
   1. Initiate the SelfRef=Start and Counter=0. Go to step 2.
   Note: The following steps until step 3 are done in the while loop
   2. While the element found in the Link list (Link(SelfRef)) is not zero
   go to step 2.1 if equal to zero go to step 3.
       2.1 Increment Counter by 1. Go to step 2.2
       2.2 Store SelfRef to LinkPos which is the index of current non-zero
       element. Go to step 2.3
       2.3 Update the SelfRef equal to Link(SelfRef). Go to step 2.4
       2.4 Store the SelfRef value to LinkArray which is the value of
       current element. Go to step 2.
   3. End of the subroutine. Return.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [LinkPos,LinkArray,Counter] = SelfLink(Link,Start)
0002 % FUNCTION SUMMARY:
0003 %   Subroutine SelfLink search the Link array in by self referencing. The
0004 %   searching process will stop until a zero is found. Every non-zero
0005 %   element found in the searching process will be stored in LinkArray and
0006 %   their corresponding index pointers will be stored in LinkPos. Couter
0007 %   will count the number of numzero element in LinkArray.
0008 %
0009 %   [LinkPos,LinkArray,Counter] = SelfLink(Link,Start)
0010 %
0011 % INPUT DATA:
0012 %   Link - N * 1 array containing the link list
0013 %   Start- scalar is the starting point of the searching process
0014 %
0015 % OUTPUT DATA:
0016 %   Counter - scalar, number of non-zero elements in LinkArray
0017 %   LinkArray - N*1 array, containing the non-zero element found in the searching
0018 %       process
0019 %   LinkPos - N*1 array, containing the index pointers of the non-zero
0020 %       elements stored in LinkArray
0021 %
0022 % INTERNAL DATA:
0023 %   SelRef - scalar, used to do searching in Link list, which is equal to
0024 %       the current found element and also pointer to the next element
0025 %
0026 % NOTE:
0027 %   1. Initiate the SelfRef=Start and Counter=0. Go to step 2.
0028 %   Note: The following steps until step 3 are done in the while loop
0029 %   2. While the element found in the Link list (Link(SelfRef)) is not zero
0030 %   go to step 2.1 if equal to zero go to step 3.
0031 %       2.1 Increment Counter by 1. Go to step 2.2
0032 %       2.2 Store SelfRef to LinkPos which is the index of current non-zero
0033 %       element. Go to step 2.3
0034 %       2.3 Update the SelfRef equal to Link(SelfRef). Go to step 2.4
0035 %       2.4 Store the SelfRef value to LinkArray which is the value of
0036 %       current element. Go to step 2.
0037 %   3. End of the subroutine. Return.
0038 
0039 %   MATPOWER
0040 %   Copyright (c) 2014-2016, Power Systems Engineering Research Center (PSERC)
0041 %   by Yujia Zhu, PSERC ASU
0042 %
0043 %   This file is part of MATPOWER.
0044 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0045 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0046 
0047     SelfRef = Start;
0048     Counter = 0;
0049     while Link(SelfRef)~=0
0050         Counter = Counter+1; % count how many linkage in this list
0051         LinkPos(Counter)=SelfRef;
0052         SelfRef = Link(SelfRef);
0053         LinkArray(Counter)=SelfRef; % create the array of the self referential link list
0054     end
0055 end

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005