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

    Two matroids M1=(V,I1), M2=(V,I2), distance metric d, initial set S0V

  • Output:

    A maximum cardinality set SV in I1I2

  • 1:

    Initialize SS0, V1={xVS:S{x}I1}, and V2={xVS:S{x}I2}

  • 2:

    while V1V2 do

  • 3:

        x*arg maxxV1V2d(x,S) and SS{x*}

  • 4:

        for all xV1 do

  • 5:

            V1V1{x} if S{x}I1

  • 6:

        for all xV2 do

  • 7:

            V2V2{x} if S{x}I2

  • 8:

    Build an augmentation graph G for S

  • 9:

    while there is a directed path from a to b in G do

  • 10:

        Let P* be a shortest path from a to b in G

  • 11:

        for all xP*{a,b} do

  • 12:

            SS{x} if xS

  • 13:

            SS{x} if xS

  • 14:

        Rebuild G for the updated S

  • 15:

    returnS