Skip to main content
. 2015 Mar 5;15(3):5344–5375. doi: 10.3390/s150305344
Function. LRP_Filtering(STP)
Method:
  1. While repeat loop pattern is found, do{

  2. (µ, λ, n_loops)←Find_RepeatLoops(trans(STP))

  3. If repeat loop pattern is found, do {

  4. For STP, combine n_loops fragments, i.e., <(sµ, tµ, Tµ),…, (sµ+λ-1, tµ+λ-1, Tµ+λ-1)>, <(sµ+λ, tµ+λ, Tµ+λ),…, (sµ+2λ-1, tµ+2λ-1, Tµ+2λ-1)>, …, <(sµ + (n_loops-1) × λ, tµ+(n_loops-1)×λ, Tµ+(n_loops-1)×λ),…, (sµ+n_loops×λ-1, tµ+n_loops×λ-1, Tµ+n_loops×λ-1)>, to form a new STP according to Definition 12.} }

  5. Return STP

Sub-Function. Find_RepeatLoops(SP)
  1. Initialize PV, HT and List as empty

  2. Suppose SP = <s0, s1, …, sn>. For each path segment si in SP, do {

  3. If si is a key in HT, let cur_pos_seg=HT[f(si)]; otherwise, insert a key-value pair (si, “null”) to HT and let cur_pos_seg=“null”. Push the pair (si, cur_pos_seg) onto PV, and get the position of this pair in PV (say new_cur_pos_seg). Set HT[f(si)] to be new_cur_pos_seg in HT.

  4. For each triple (b_pos, e_pos, cur_pos) in List, do {

  5. If PV[cur_pos+1].s equals to si, do {

  6. If (cur_pos+1) equals to e_pos, repeat loops are found. Let µ be b_pos, λ be e_pos-b_pos+1. Call n_loops←Test_RepeatLoops(SP, µ, λ, 2). Return the triple (µ,λ, n_loops) and exit this sub-function. Otherwise, let cur_pos++ and update this triple in List. }

  7. Else delete this triple from List. }

  8. If cur_pos_seg equals to new_cur_pos_seg-1, repeat loops are found. Let µ be cur_pos_seg and λ be 1. Call n_loops←Test_RepeatLoops(SP, µ, λ, 2). Return the triple (µ,λ, n_loops) and exit this sub-function.

  9. While cur_pos_seg isn’t “null”, do {

  10. Generate a candidate triple (cur_pos_seg, new_cur_pos_seg-1, cur_pos_seg) and add it to List. Let cur_pos_seg = PV[cur_pos_seg].pos.}}

  11. No repeat loop pattern is found. Return the triple (“null”, “null”, “null”).

Sub-Function. Test_RepeatLoops(SP, µ, λ, n_loops)
  1. If μ + (n_loops + 1) × λ − 1 ≤ n and <sμ, sμ+1, …, sμ+λ-1> = <sμ+n_loops×λ, sμ+n_loops×λ+1, …, sμ+(n_loops+1)×λ-1>, n_loops++ and then call n_loops←Test_RepeatLoops(SP, µ, λ, n_loops).

  2. Return n_loops.