Skip to main content
. 2023 Jul 14;25(7):1066. doi: 10.3390/e25071066
Algorithm 3 SFDM2
  • Input:

    Stream X=i=1mXi, distance metric d, parameter ε(0,1), size constraints k1,,kmZ+ (k=i=1mki)

  • Output:

    A set SX s.t. |SXi|=ki, i[m]

  • Stream processing

  • 1:

    U={dmin(1ε)j:jZ0+(1ε)jdmindmax}

  • 2:

    Initialize Sμ,Sμ,i= for every μU and i[m]

  • 3:

    for all xX do

  • 4:

        for all μU and i[m] do

  • 5:

            Run Lines 3–6 of Algorithm 1 to update Sμ w.r.t. x

  • 6:

            if c(x)=i then

  • 7:

               Run Lines 3–6 of Algorithm 1 to update Sμ,i w.r.t. x

  • Post-processing

  • 8:

    U={μU:|Sμ|=k|Sμ,i|ki,i[m]}

  • 9:

    for all μU do

  • 10:

        For each group i[m], pick min(ki,|SμXi|) elements arbitrarily from Sμ as Sμ

  • 11:

        Let Sall=(i=1mSμ,i)Sμ and l=|Sall|

  • 12:

        Create l clusters C={C1,,Cl}, each of which contains one element in Sall

  • 13:

        while there exist Ca,CbC s.t. d(x,y)<μm+1 for some xCa and yCb do

  • 14:

            Merge Ca,Cb into a new cluster C=CaCb

  • 15:

            CC{Ca,Cb}{C}

  • 16:

        Let M1=(Sall,I1) and M2=(Sall,I2) be two matroids, where SI1 iff |SXi|ki, i[m] and SI2 iff |SC|1, CC

  • 17:

        Run Algorithm 4 to augment Sμ such that Sμ is a maximum cardinality set in I1I2

  • 18:

    return Sarg maxμU:|Sμ|=kdiv(Sμ)