Skip to main content
. 2013 Oct;20(10):738–754. doi: 10.1089/cmb.2013.0073

Procedure.

ComputeNumSolutions(G, S, Inline graphic, PΣ, PΔ, PΘ)

1: for each Inline graphic and Inline graphicdo
2:   Initialize c(g, s), cΣ(g, s), cΔ(g, s), and cΘ(g, s) to ∞, and N(g, s) to 0.
3: for each Inline graphicdo
4:   Initialize c(g,Inline graphic (g)) to 0, and N(g,Inline graphic (g)) to 1.
5: for each Inline graphic in post-order do
6:   for each Inline graphic in post-order do
7:    Let {g′, g″} = ChG(g).
8:     ifInline graphicthen
9:   cΣ(g, s) = ∞.
10:   cΔ(g, s) = PΔ + c(g′, s) + c(g″, s).
11:   cΘ(g, s) = PΘ + min{in(g′, s) + out(g″, s), in(g″, s) + out(g′, s)}.
12:   c(g, s) = min{cΣ(g, s), cΔ(g, s), cΘ(g, s)}.
13:   Assign the three ai expressions as described earlier (for the case when Inline graphic and, for each Inline graphic, compute N(ai) using Equation 2.
14:   Compute N(g, s) using Equation 3.
15:  else
16:   Let {s′, s″} = ChS(s).
17:   cΣ(g, s) = min{in(g′, s′) + in(g″, s″), in(g″, s′) + in(g′, s″)}.
18:   Inline graphic
19:   If s ≠ rt(S), then cΘ(g, s) = PΘ + min{in(g′, s) + out(g″, s), in(g″, s) + out(g′, s)}.
20:   c(g, s) = min{cΣ(g, s), cΔ(g, s), cΘ(g, s)}.
21:   ifs ≠ rt(S) then
22:    Assign the thirteen ai expressions as described earlier (for the case when Inline graphic and compute N(ai), for each Inline graphic, using Equation 2.
23:    Compute N(g, s) using Equation 1.
24:   ifs = rt(S) then
25:    Assign the eleven ai expressions as described earlier (for the case when s = rt(S)) and compute N(ai), for each Inline graphic, using Equation 2.
26:    Compute N(g, s) using Equation 4.