_mw_matc.c
Upload User: gzelex
Upload Date: 2007-01-07
Package Size: 707k
Code Size: 51k
Development Platform:

MultiPlatform

  1. /*******************************************************************************
  2. +
  3. +  LEDA-R  3.2.3
  4. +
  5. +  _mw_matc.c
  6. +
  7. +  Copyright (c) 1995  by  Max-Planck-Institut fuer Informatik
  8. +  Im Stadtwald, 66123 Saarbruecken, Germany     
  9. +  All rights reserved.
  10. *******************************************************************************/
  11. /* This file has been automatically generated from "max_weight_matching.w"
  12.    by CTANGLE (Version 3.1 [km2c]) */
  13. #include <LEDA/basic.h>
  14. #include <LEDA/list.h>
  15. #include <LEDA/ugraph.h>
  16. typedef num_type GEWICHT_TYP;
  17. typedef num_type DUALER_TYP;
  18. typedef list <edge >KANTENLISTE;
  19. #if !defined(TEMPLATE_FUNCTIONS)
  20. int compare(const KANTENLISTE&, const KANTENLISTE&) { return 0; }
  21. LEDA_TYPE_PARAMETER(KANTENLISTE)
  22. #endif
  23. #define GENAUIGKEIT 1e-10
  24. enum MARKENTYP {
  25.   S = -1, UNMARKIERT, T
  26. };
  27. class blossom {
  28.  public:
  29.   list <list_item >ub_zeiger_liste;
  30.   list <edge >kantenliste;
  31.   node basis;
  32.   DUALER_TYP z;
  33.   list <node >knotenliste;
  34.   MARKENTYP typ;
  35.   edge kante;
  36.   edge d3_kante;
  37.   list <edge >adj_s_blossoms;
  38.    blossom() {
  39.     ub_zeiger_liste.clear();
  40.     kantenliste.clear();
  41.     knotenliste.clear();
  42.     adj_s_blossoms.clear();
  43.     basis = nil;
  44.     z = 0;
  45.     typ = UNMARKIERT;
  46.     kante = nil;
  47.     d3_kante = nil;
  48.   }
  49.    blossom(const list <list_item >&zliste, const list <edge >&eliste,
  50.      const list <node >&nliste, const node b) {
  51.     ub_zeiger_liste = zliste;
  52.     kantenliste = eliste;
  53.     knotenliste = nliste;
  54.     adj_s_blossoms.clear();
  55.     basis = b;
  56.     z = 0;
  57.     typ = S;
  58.     kante = nil;
  59.     d3_kante = nil;
  60.   }
  61.   bool operator == (const blossom & bl) {
  62.     return 0;
  63.   }
  64. };
  65. #if !defined(TEMPLATE_FUNCTIONS)
  66. int compare(const blossom&, const blossom&) { return 0; }
  67. LEDA_TYPE_PARAMETER(blossom)
  68. #endif
  69. int markiere
  70.  (const ugraph &G,
  71.    const edge_array <GEWICHT_TYP > &gewicht,
  72.    const node_array <DUALER_TYP > &u,
  73.    const edge_array <bool >&gematcht,
  74.    const node_array <list_item >&blossom_zu_knoten,
  75.    const node_array <edge >&gematchte_kante,
  76.    list <blossom > &blossomliste,
  77.    list <node >&ungescannt,
  78.    node_array <KANTENLISTE > &brauchbare_kanten,
  79.    list <edge >&pfad,
  80.    node_array <edge >&d2_kante);
  81. void rek_erweitere
  82.  (const ugraph &G,
  83.    edge_array <bool >&gematcht,
  84.    list <blossom > &unterblossomliste,
  85.    blossom & bl,
  86.    node j);
  87. void erweitere
  88.  (const ugraph &G,
  89.    const edge_array <GEWICHT_TYP > &gewicht,
  90.    const node_array <list_item >&blossom_zu_knoten,
  91.    const node_array <DUALER_TYP > &u,
  92.    const list <edge >&pfad,
  93.    edge_array <bool >&gematcht,
  94.    list <blossom > &blossomliste,
  95.    list <blossom > &unterblossomliste,
  96.    list <node >&ungescannt,
  97.    node_array <edge >&gematchte_kante,
  98.    node_array <KANTENLISTE > &brauchbare_kanten,
  99.    node_array <edge >&d2_kante);
  100. int aendere_duale_variablen
  101.  (const ugraph &G,
  102.    const edge_array <GEWICHT_TYP > &gewicht,
  103.    const edge_array <bool >&gematcht,
  104.    const node_array <list_item >&blossom_zu_knoten,
  105.    const node_array <edge >&gematchte_kante,
  106.    list <blossom > &blossomliste,
  107.    node_array <DUALER_TYP > &u,
  108.    list <node >&ungescannt,
  109.    node_array <KANTENLISTE > &brauchbare_kanten,
  110.    const node_array <edge >&d2_kante);
  111. void bilde_blossom
  112.  (const ugraph &G,
  113.    const edge_array <GEWICHT_TYP > &gewicht,
  114.    const node_array <DUALER_TYP > &u,
  115.    const edge_array <bool >&gematcht,
  116.    const list <edge >&pfad,
  117.    list <blossom > &blossomliste,
  118.    list <blossom > &unterblossomliste,
  119.    list <node >&ungescannt,
  120.    node_array <list_item >&blossom_zu_knoten,
  121.    node_array <KANTENLISTE > &brauchbare_kanten,
  122.    node_array <edge >&d2_kante);
  123. void expandiere_blossoms
  124.  (const ugraph &G,
  125.    const edge_array <GEWICHT_TYP > &gewicht,
  126.    const node_array <DUALER_TYP > &u,
  127.    const edge_array <bool >&gematcht,
  128.    list <blossom > &blossomliste,
  129.    list <blossom > &unterblossomliste,
  130.    list <node >&ungescannt,
  131.    node_array <list_item >&blossom_zu_knoten,
  132.    node_array <KANTENLISTE > &brauchbare_kanten,
  133.    node_array <edge >&d2_kante);
  134. void neues_s_blossom
  135.  (const ugraph &G,
  136.    const edge_array <GEWICHT_TYP > &gewicht,
  137.    const node_array <DUALER_TYP > &u,
  138.    list <blossom > &blossomliste,
  139.    const node_array <list_item >&blossom_zu_knoten,
  140.    const edge_array <bool >&gematcht,
  141.    blossom & bl,
  142.    list <node >&ungescannt,
  143.    node_array <KANTENLISTE > &brauchbare_kanten,
  144.    node_array <edge >&d2_kante);
  145. void aktualisiere_knotenliste
  146.  (list <blossom > &unterblossomliste,
  147.    blossom & bl);
  148. void matchingtest
  149.  (const ugraph &G,
  150.    const edge_array <bool >&gematcht);
  151. void bed1test
  152.  (const ugraph &G,
  153.    const edge_array <GEWICHT_TYP > &gewicht,
  154.    const node_array <DUALER_TYP > &u,
  155.    const list <blossom > &blossomliste,
  156.    const list <blossom > &unterblossomliste,
  157.    const node_array <list_item >&blossom_zu_knoten);
  158. void bed2test
  159.  (const ugraph &G,
  160.    const edge_array <GEWICHT_TYP > &gewicht,
  161.    const list <blossom > &blossomliste,
  162.    const list <blossom > &unterblossomliste,
  163.    const node_array <list_item >&blossom_zu_knoten,
  164.    const edge_array <bool >&gematcht,
  165.    const node_array <DUALER_TYP > &u);
  166. void bed3test
  167.  (const ugraph &G,
  168.    const node_array <DUALER_TYP > &u,
  169.    const node_array <edge >&gematchte_kante);
  170. void bed4test
  171.  (const ugraph &G,
  172.    const list <blossom > &blossomliste,
  173.    const list <blossom > &unterblossomliste,
  174.    const node_array <edge >&gematchte_kante,
  175.    const node_array <list_item >&blossom_zu_knoten);
  176. DUALER_TYP bestimme_z
  177.  (const ugraph &G,
  178.    const list <blossom > &blossomliste,
  179.    const list <blossom > &unterblossomliste,
  180.    const blossom & bl,
  181.    const edge &e);
  182. list <edge >MAX_WEIGHTED_MATCHING (const ugraph &G, 
  183.                                    const edge_array <GEWICHT_TYP > &gewicht) 
  184. {
  185.   edge_array <bool >gematcht;
  186.   gematcht.init(G, false);
  187.   list <blossom > blossomliste;
  188.   list <blossom > unterblossomliste;
  189.   node i;
  190.   forall_nodes (i, G) {
  191.     list <list_item >l1;
  192.     list <edge >l2;
  193.     list <node >l3;
  194.     blossomliste.append(blossom(l1, l2, l3, i));
  195.   }
  196.   node_array <list_item >blossom_zu_knoten(G);
  197.   if (!blossomliste.empty()) {
  198.     list_item lit = blossomliste.first();
  199.     while (lit != nil) {
  200.       node i = blossomliste[lit].basis;
  201.       blossom_zu_knoten[i] = lit;
  202.       lit = blossomliste.succ(lit);
  203.     }
  204.   }
  205.   node_array <DUALER_TYP > u(G);
  206.   GEWICHT_TYP w_max = 0;
  207.   edge e;
  208.   forall_edges (e, G) {
  209.     if (gewicht[e] > w_max)
  210.       w_max = gewicht[e];
  211.   }
  212.   u.init(G, num_type(w_max / 2.0));
  213.   node_array <edge >gematchte_kante(G, nil);
  214.   list <edge >l;
  215.   node_array <KANTENLISTE > brauchbare_kanten(G, l);
  216.   list <node >ungescannt;
  217.   node_array <bool >schon_eingefuegt(G, false);
  218.   forall_edges (e, G) {
  219.     if ((gewicht[e] == w_max) ||
  220.       ((gewicht[e] < w_max) && (w_max - gewicht[e] < GENAUIGKEIT)) ||
  221.       ((gewicht[e] > w_max) && (gewicht[e] - w_max < GENAUIGKEIT))) {
  222.       if (schon_eingefuegt[G.source(e)] == false) {
  223. ungescannt.append(G.source(e));
  224. schon_eingefuegt[G.source(e)] = true;
  225.       }
  226.       if (schon_eingefuegt[G.target(e)] == false) {
  227. ungescannt.append(G.target(e));
  228. schon_eingefuegt[G.target(e)] = true;
  229.       }
  230.       brauchbare_kanten[G.source(e)].append(e);
  231.       brauchbare_kanten[G.target(e)].append(e);
  232.     }
  233.   }
  234.   list <edge >pfad;
  235.   node_array <edge >d2_kante(G, nil);
  236.   bool maximal = false;
  237.   while (!maximal) {
  238.     pfad.clear();
  239.     int erg_markiere = markiere
  240.     (G, gewicht, u, gematcht, blossom_zu_knoten, gematchte_kante,
  241.       blossomliste, ungescannt, brauchbare_kanten, pfad, d2_kante);
  242.     if (erg_markiere > 0) {
  243.       erweitere
  244. (G, gewicht, blossom_zu_knoten, u, pfad, gematcht, blossomliste,
  245. unterblossomliste, ungescannt, gematchte_kante, brauchbare_kanten, d2_kante);
  246.     }
  247.     else if (erg_markiere < 0) {
  248.       bilde_blossom
  249. (G, gewicht, u, gematcht, pfad, blossomliste, unterblossomliste, ungescannt,
  250. blossom_zu_knoten, brauchbare_kanten, d2_kante);
  251.     }
  252.     else if (erg_markiere == 0) {
  253.       int erg_aendere = aendere_duale_variablen
  254.       (G, gewicht, gematcht, blossom_zu_knoten, gematchte_kante,
  255. blossomliste, u, ungescannt, brauchbare_kanten, d2_kante);
  256.       if (erg_aendere > 0)
  257. maximal = true;
  258.       else if (erg_aendere < 0) {
  259. expandiere_blossoms
  260.   (G, gewicht, u, gematcht, blossomliste, unterblossomliste, ungescannt,
  261.   blossom_zu_knoten, brauchbare_kanten, d2_kante);
  262.       }
  263.     }
  264.   }
  265.   matchingtest(G, gematcht);
  266.   bed1test(G, gewicht, u, blossomliste, unterblossomliste, blossom_zu_knoten);
  267.   bed2test(G, gewicht, blossomliste, unterblossomliste, blossom_zu_knoten, gematcht, u);
  268.   bed3test(G, u, gematchte_kante);
  269.   bed4test(G, blossomliste, unterblossomliste, gematchte_kante, blossom_zu_knoten);
  270.   list <edge >matching;
  271.   forall_edges (e, G)
  272.     if (gematcht[e] == true) {
  273.       matching.append(e);
  274.     }
  275.   return matching;
  276. }
  277. int markiere
  278.  (const ugraph &G,
  279.    const edge_array <GEWICHT_TYP > &gewicht,
  280.    const node_array <DUALER_TYP > &u,
  281.    const edge_array <bool >&gematcht,
  282.    const node_array <list_item >&blossom_zu_knoten,
  283.    const node_array <edge >&gematchte_kante,
  284.    list <blossom > &blossomliste,
  285.    list <node >&ungescannt,
  286.    node_array <KANTENLISTE > &brauchbare_kanten,
  287.    list <edge >&pfad,
  288.    node_array <edge >&d2_kante) {
  289.   if (!ungescannt.empty()) {
  290.     list_item lit_ungescannt = ungescannt.first();
  291.     while (lit_ungescannt != nil) {
  292.       node i = ungescannt.pop();
  293.       while (!brauchbare_kanten[i].empty()) {
  294. edge e = brauchbare_kanten[i].pop();
  295. node j = G.opposite(i, e);
  296. if (blossomliste[blossom_zu_knoten[j]].typ == UNMARKIERT) {
  297.   blossomliste[blossom_zu_knoten[j]].typ = T;
  298.   blossomliste[blossom_zu_knoten[j]].kante = e;
  299.   node b = blossomliste[blossom_zu_knoten[j]].basis;
  300.   edge e_gematcht = gematchte_kante[b];
  301.   list_item bllit = blossom_zu_knoten[G.opposite(b, e_gematcht)];
  302.   blossomliste[bllit].typ = S;
  303.   blossomliste[bllit].kante = e_gematcht;
  304.   neues_s_blossom
  305.     (G, gewicht, u, blossomliste, blossom_zu_knoten, gematcht, blossomliste[bllit],
  306.     ungescannt, brauchbare_kanten, d2_kante);
  307. }
  308. else if ((blossomliste[blossom_zu_knoten[j]].typ == S) &&
  309.   (blossom_zu_knoten[i] != blossom_zu_knoten[j])) {
  310.   ungescannt.push(i);
  311.   node start[2];
  312.   start[0] = i;
  313.   start[1] = j;
  314.   list <edge >alt_pfad[2];
  315.   for (int index = 0; index < 2; index++) {
  316.     edge kante = blossomliste[blossom_zu_knoten[start[index]]].kante;
  317.     while (kante != nil) {
  318.       node s = G.source(kante);
  319.       node t = G.target(kante);
  320.       alt_pfad[index].push(kante);
  321.       if (blossom_zu_knoten[s] == blossom_zu_knoten[start[index]]) {
  322. start[index] = t;
  323.       }
  324.       else {
  325. start[index] = s;
  326.       }
  327.       kante = blossomliste[blossom_zu_knoten[start[index]]].kante;
  328.     }
  329.     start[index] = blossomliste[blossom_zu_knoten[start[index]]].basis;
  330.   }
  331.   if (start[0] == start[1]) {
  332.     while (alt_pfad[0].head() == alt_pfad[1].head()) {
  333.       alt_pfad[0].pop();
  334.       alt_pfad[1].pop();
  335.     }
  336.     pfad = alt_pfad[0];
  337.     pfad.append(e);
  338.     if (!alt_pfad[1].empty()) {
  339.       list_item lit = alt_pfad[1].last();
  340.       while (lit != nil) {
  341. pfad.append(alt_pfad[1].inf(lit));
  342. lit = alt_pfad[1].pred(lit);
  343.       }
  344.     }
  345.     return -1;
  346.   }
  347.   else {
  348.     pfad = alt_pfad[0];
  349.     pfad.append(e);
  350.     if (!alt_pfad[1].empty()) {
  351.       list_item lit = alt_pfad[1].last();
  352.       while (lit != nil) {
  353. pfad.append(alt_pfad[1].inf(lit));
  354. lit = alt_pfad[1].pred(lit);
  355.       }
  356.     }
  357.     return 1;
  358.   }
  359. }
  360. else if (blossomliste[blossom_zu_knoten[j]].typ == T) {
  361.   brauchbare_kanten[j].append(e);
  362. }
  363.       }
  364.       lit_ungescannt = ungescannt.first();
  365.     }
  366.   }
  367.   if (ungescannt.empty())
  368.     return 0;
  369. }
  370. void neues_s_blossom
  371.  (const ugraph &G,
  372.    const edge_array <GEWICHT_TYP > &gewicht,
  373.    const node_array <DUALER_TYP > &u,
  374.    list <blossom > &blossomliste,
  375.    const node_array <list_item >&blossom_zu_knoten,
  376.    const edge_array <bool >&gematcht,
  377.    blossom & bl,
  378.    list <node >&ungescannt,
  379.    node_array <KANTENLISTE > &brauchbare_kanten,
  380.    node_array <edge >&d2_kante) {
  381.   if (!bl.knotenliste.empty()) {
  382.     list_item knotenlit = bl.knotenliste.first();
  383.     while (knotenlit != nil) {
  384.       node i = bl.knotenliste.inf(knotenlit);
  385.       edge e;
  386.       bool knoten_brauchbar = false;
  387.       brauchbare_kanten[i].clear();
  388.       d2_kante[i] = nil;
  389.       forall_adj_edges (e, i) {
  390. if (gematcht[e] == false) {
  391.   list_item litsource = blossom_zu_knoten[G.source(e)];
  392.   list_item littarget = blossom_zu_knoten[G.target(e)];
  393.   if (litsource != littarget) {
  394.     DUALER_TYP pi = u[G.source(e)] + u[G.target(e)] - gewicht[e];
  395.     if ((pi == 0) ||
  396.       (pi < 0 && (-pi) < GENAUIGKEIT) ||
  397.       (pi > 0 && pi < GENAUIGKEIT)) {
  398.       brauchbare_kanten[i].append(e);
  399.       knoten_brauchbar = true;
  400.     }
  401.     else {
  402.       list_item bllit;
  403.       node j;
  404.       if (G.source(e) == i) {
  405. bllit = littarget;
  406. j = G.target(e);
  407.       }
  408.       else {
  409. bllit = litsource;
  410. j = G.source(e);
  411.       }
  412.       if ((blossomliste[bllit].typ == UNMARKIERT) ||
  413. (blossomliste[bllit].typ == T)) {
  414. if (d2_kante[j] != nil) {
  415.   edge min_e = d2_kante[j];
  416.   DUALER_TYP pi_j;
  417.   pi_j = u[G.source(min_e)] + u[G.target(min_e)] - gewicht[min_e];
  418.   if (pi < pi_j)
  419.     d2_kante[j] = e;
  420. }
  421. else
  422.   d2_kante[j] = e;
  423.       }
  424.       else if (blossomliste[bllit].typ == S) {
  425. if ((pi != 0) ||
  426.   (pi < 0 && (-pi) < GENAUIGKEIT) ||
  427.   (pi > 0 && pi < GENAUIGKEIT)) {
  428.   blossomliste[litsource].adj_s_blossoms.append(e);
  429.   blossomliste[littarget].adj_s_blossoms.append(e);
  430. }
  431. if (bl.d3_kante != nil) {
  432.   edge min_e = bl.d3_kante;
  433.   DUALER_TYP pi_j;
  434.   pi_j = u[G.source(min_e)] + u[G.target(min_e)] - gewicht[min_e];
  435.   if (pi < pi_j)
  436.     bl.d3_kante = e;
  437. }
  438. else
  439.   bl.d3_kante = e;
  440. if (blossomliste[bllit].d3_kante != nil) {
  441.   edge min_e = blossomliste[bllit].d3_kante;
  442.   DUALER_TYP pi_j;
  443.   pi_j = u[G.source(min_e)] + u[G.target(min_e)] - gewicht[min_e];
  444.   if (pi < pi_j)
  445.     blossomliste[bllit].d3_kante = e;
  446. }
  447. else
  448.   blossomliste[bllit].d3_kante = e;
  449.       }
  450.     }
  451.   }
  452. }
  453.       }
  454.       if (knoten_brauchbar == true)
  455. ungescannt.push(i);
  456.       knotenlit = bl.knotenliste.succ(knotenlit);
  457.     }
  458.   }
  459.   else {
  460.     node i = bl.basis;
  461.     edge e;
  462.     bool knoten_brauchbar = false;
  463.     brauchbare_kanten[i].clear();
  464.     d2_kante[i] = nil;
  465.     forall_adj_edges (e, i) {
  466.       if (gematcht[e] == false) {
  467. list_item litsource = blossom_zu_knoten[G.source(e)];
  468. list_item littarget = blossom_zu_knoten[G.target(e)];
  469. if (litsource != littarget) {
  470.   DUALER_TYP pi = u[G.source(e)] + u[G.target(e)] - gewicht[e];
  471.   if ((pi == 0) ||
  472.     (pi < 0 && (-pi) < GENAUIGKEIT) ||
  473.     (pi > 0 && pi < GENAUIGKEIT)) {
  474.     brauchbare_kanten[i].append(e);
  475.     knoten_brauchbar = true;
  476.   }
  477.   else {
  478.     list_item bllit;
  479.     node j;
  480.     if (G.source(e) == i) {
  481.       bllit = littarget;
  482.       j = G.target(e);
  483.     }
  484.     else {
  485.       bllit = litsource;
  486.       j = G.source(e);
  487.     }
  488.     if ((blossomliste[bllit].typ == UNMARKIERT) ||
  489.       (blossomliste[bllit].typ == T)) {
  490.       if (d2_kante[j] != nil) {
  491. edge min_e = d2_kante[j];
  492. DUALER_TYP pi_j;
  493. pi_j = u[G.source(min_e)] + u[G.target(min_e)] - gewicht[min_e];
  494. if (pi < pi_j)
  495.   d2_kante[j] = e;
  496.       }
  497.       else
  498. d2_kante[j] = e;
  499.     }
  500.     else if (blossomliste[bllit].typ == S) {
  501.       if ((pi != 0) ||
  502. (pi < 0 && (-pi) < GENAUIGKEIT) ||
  503. (pi > 0 && pi < GENAUIGKEIT)) {
  504. blossomliste[litsource].adj_s_blossoms.append(e);
  505. blossomliste[littarget].adj_s_blossoms.append(e);
  506.       }
  507.       if (bl.d3_kante != nil) {
  508. edge min_e = bl.d3_kante;
  509. DUALER_TYP pi_j;
  510. pi_j = u[G.source(min_e)] + u[G.target(min_e)] - gewicht[min_e];
  511. if (pi < pi_j)
  512.   bl.d3_kante = e;
  513.       }
  514.       else
  515. bl.d3_kante = e;
  516.       if (blossomliste[bllit].d3_kante != nil) {
  517. edge min_e = blossomliste[bllit].d3_kante;
  518. DUALER_TYP pi_j;
  519. pi_j = u[G.source(min_e)] + u[G.target(min_e)] - gewicht[min_e];
  520. if (pi < pi_j)
  521.   blossomliste[bllit].d3_kante = e;
  522.       }
  523.       else
  524. blossomliste[bllit].d3_kante = e;
  525.     }
  526.   }
  527. }
  528.       }
  529.     }
  530.     if (knoten_brauchbar == true)
  531.       ungescannt.push(i);
  532.   }
  533. }
  534. void erweitere
  535.  (const ugraph &G,
  536.    const edge_array <GEWICHT_TYP > &gewicht,
  537.    const node_array <list_item >&blossom_zu_knoten,
  538.    const node_array <DUALER_TYP > &u,
  539.    const list <edge >&pfad,
  540.    edge_array <bool >&gematcht,
  541.    list <blossom > &blossomliste,
  542.    list <blossom > &unterblossomliste,
  543.    list <node >&ungescannt,
  544.    node_array <edge >&gematchte_kante,
  545.    node_array <KANTENLISTE > &brauchbare_kanten,
  546.    node_array <edge >&d2_kante) {
  547.   if (!pfad.empty()) {
  548.     list_item lit = pfad.first();
  549.     while (lit != nil) {
  550.       edge e = pfad.inf(lit);
  551.       if (gematcht[e] == true) {
  552. gematcht[e] = false;
  553.       }
  554.       else {
  555. gematcht[e] = true;
  556. node s = G.source(e);
  557. node t = G.target(e);
  558. if (s != blossomliste[blossom_zu_knoten[s]].basis) {
  559.   rek_erweitere
  560.     (G, gematcht, unterblossomliste, blossomliste[blossom_zu_knoten[s]], s);
  561.   aktualisiere_knotenliste
  562.     (unterblossomliste, blossomliste[blossom_zu_knoten[s]]);
  563. }
  564. if (t != blossomliste[blossom_zu_knoten[t]].basis) {
  565.   rek_erweitere
  566.     (G, gematcht, unterblossomliste, blossomliste[blossom_zu_knoten[t]], t);
  567.   aktualisiere_knotenliste
  568.     (unterblossomliste, blossomliste[blossom_zu_knoten[t]]);
  569. }
  570.       }
  571.       lit = pfad.succ(lit);
  572.     }
  573.   }
  574.   gematchte_kante.init(G, nil);
  575.   edge e;
  576.   forall_edges (e, G) {
  577.     if (gematcht[e] == true) {
  578.       gematchte_kante[G.source(e)] = e;
  579.       gematchte_kante[G.target(e)] = e;
  580.     }
  581.   }
  582.   list <edge >l;
  583.   brauchbare_kanten.init(G, l);
  584.   ungescannt.clear();
  585.   d2_kante.init(G, nil);
  586.   if (!blossomliste.empty()) {
  587.     list_item bllit = blossomliste.first();
  588.     while (bllit != nil) {
  589.       blossomliste[bllit].typ = UNMARKIERT;
  590.       blossomliste[bllit].d3_kante = nil;
  591.       blossomliste[bllit].kante = nil;
  592.       blossomliste[bllit].adj_s_blossoms.clear();
  593.       bllit = blossomliste.succ(bllit);
  594.     }
  595.   }
  596.   if (!blossomliste.empty()) {
  597.     list_item bllit = blossomliste.first();
  598.     while (bllit != nil) {
  599.       if (gematchte_kante[blossomliste[bllit].basis] == nil) {
  600. blossomliste[bllit].typ = S;
  601. neues_s_blossom
  602.   (G, gewicht, u, blossomliste, blossom_zu_knoten, gematcht,
  603.   blossomliste[bllit], ungescannt, brauchbare_kanten, d2_kante);
  604.       }
  605.       bllit = blossomliste.succ(bllit);
  606.     }
  607.   }
  608. }
  609. void rek_erweitere
  610.  (const ugraph &G,
  611.    edge_array <bool >&gematcht,
  612.    list <blossom > &unterblossomliste,
  613.    blossom & bl,
  614.    node j) {
  615.   list_item knotenlit = bl.knotenliste.first();
  616.   node i = bl.knotenliste.inf(knotenlit);
  617.   list_item ubzlit = bl.ub_zeiger_liste.first();
  618.   list_item ubllit = bl.ub_zeiger_liste[ubzlit];
  619.   list_item kantenlit = bl.kantenliste.first();
  620.   while (i != j) {
  621.     node b = unterblossomliste[ubllit].basis;
  622.     if (i == b) {
  623.       ubzlit = bl.ub_zeiger_liste.succ(ubzlit);
  624.       ubllit = bl.ub_zeiger_liste[ubzlit];
  625.       kantenlit = bl.kantenliste.succ(kantenlit);
  626.     }
  627.     knotenlit = bl.knotenliste.succ(knotenlit);
  628.     i = bl.knotenliste.inf(knotenlit);
  629.   }
  630.   list <edge >pfad;
  631.   list <list_item >ub_liste;
  632.   list <node >exitknotenliste;
  633.   list_item hklit = kantenlit;
  634.   list_item hzlit = ubzlit;
  635.   if (gematcht[bl.kantenliste.inf(kantenlit)] == true) {
  636.     while (kantenlit != nil) {
  637.       pfad.append(bl.kantenliste.inf(kantenlit));
  638.       kantenlit = bl.kantenliste.pred(kantenlit);
  639.       ub_liste.append(bl.ub_zeiger_liste[ubzlit]);
  640.       ubzlit = bl.ub_zeiger_liste.pred(ubzlit);
  641.     }
  642.     ubzlit = bl.ub_zeiger_liste.last();
  643.     ub_liste.append(bl.ub_zeiger_liste[ubzlit]);
  644.   }
  645.   else {
  646.     kantenlit = bl.kantenliste.succ(kantenlit);
  647.     while (kantenlit != nil) {
  648.       pfad.append(bl.kantenliste.inf(kantenlit));
  649.       kantenlit = bl.kantenliste.succ(kantenlit);
  650.       ub_liste.append(bl.ub_zeiger_liste[ubzlit]);
  651.       ubzlit = bl.ub_zeiger_liste.succ(ubzlit);
  652.     }
  653.     ub_liste.append(bl.ub_zeiger_liste[ubzlit]);
  654.   }
  655.   kantenlit = pfad.first();
  656.   while (kantenlit != nil) {
  657.     edge e = pfad.inf(kantenlit);
  658.     if (gematcht[e] == true) {
  659.       gematcht[e] = false;
  660.     }
  661.     else {
  662.       gematcht[e] = true;
  663.       exitknotenliste.append(G.source(e));
  664.       exitknotenliste.append(G.target(e));
  665.     }
  666.     kantenlit = pfad.succ(kantenlit);
  667.   }
  668.   list <list_item >ubzliste[2];
  669.   ubzlit = hzlit;
  670.   kantenlit = hklit;
  671.   ubzlit = bl.ub_zeiger_liste.succ(ubzlit);
  672.   bl.ub_zeiger_liste.split(ubzlit, ubzliste[0], ubzliste[1]);
  673.   bl.ub_zeiger_liste.conc(ubzliste[1]);
  674.   bl.ub_zeiger_liste.conc(ubzliste[0]);
  675.   list <edge >kaliste[2];
  676.   kantenlit = bl.kantenliste.succ(kantenlit);
  677.   bl.kantenliste.split(kantenlit, kaliste[0], kaliste[1]);
  678.   bl.kantenliste.conc(kaliste[1]);
  679.   bl.kantenliste.conc(kaliste[0]);
  680.   bl.basis = j;
  681.   list_item lit = ub_liste.pop();
  682.   node b = unterblossomliste[lit].basis;
  683.   if (j != b) {
  684.     rek_erweitere
  685.       (G, gematcht, unterblossomliste, unterblossomliste[lit], j);
  686.     aktualisiere_knotenliste
  687.       (unterblossomliste, unterblossomliste[lit]);
  688.   }
  689.   while (!exitknotenliste.empty()) {
  690.     node k = exitknotenliste.pop();
  691.     node l = exitknotenliste.pop();
  692.     list_item lit = ub_liste.pop();
  693.     list_item lit2 = ub_liste.pop();
  694.     if ((!unterblossomliste[lit].knotenliste.empty()) &&
  695.       (!unterblossomliste[lit2].knotenliste.empty())) {
  696.       list_item knotenlit = unterblossomliste[lit].knotenliste.first();
  697.       while (knotenlit != nil) {
  698. node hilfsknoten = unterblossomliste[lit].knotenliste[knotenlit];
  699. if (hilfsknoten == k) {
  700.   if (k != unterblossomliste[lit].basis) {
  701.     rek_erweitere
  702.       (G, gematcht, unterblossomliste, unterblossomliste[lit], k);
  703.     aktualisiere_knotenliste
  704.       (unterblossomliste, unterblossomliste[lit]);
  705.   }
  706.   if (l != unterblossomliste[lit2].basis) {
  707.     rek_erweitere
  708.       (G, gematcht, unterblossomliste, unterblossomliste[lit2], l);
  709.     aktualisiere_knotenliste
  710.       (unterblossomliste, unterblossomliste[lit2]);
  711.   }
  712.   break;
  713. }
  714. else if (hilfsknoten == l) {
  715.   if (l != unterblossomliste[lit].basis) {
  716.     rek_erweitere
  717.       (G, gematcht, unterblossomliste, unterblossomliste[lit], l);
  718.     aktualisiere_knotenliste
  719.       (unterblossomliste, unterblossomliste[lit]);
  720.   }
  721.   if (k != unterblossomliste[lit2].basis) {
  722.     rek_erweitere
  723.       (G, gematcht, unterblossomliste, unterblossomliste[lit2], k);
  724.     aktualisiere_knotenliste
  725.       (unterblossomliste, unterblossomliste[lit2]);
  726.   }
  727.   break;
  728. }
  729. knotenlit = unterblossomliste[lit].knotenliste.succ(knotenlit);
  730.       }
  731.     }
  732.     else if ((unterblossomliste[lit].knotenliste.empty()) &&
  733.       (!unterblossomliste[lit2].knotenliste.empty())) {
  734.       if (k == unterblossomliste[lit].basis) {
  735. if (l != unterblossomliste[lit2].basis) {
  736.   rek_erweitere
  737.     (G, gematcht, unterblossomliste, unterblossomliste[lit2], l);
  738.   aktualisiere_knotenliste
  739.     (unterblossomliste, unterblossomliste[lit2]);
  740. }
  741.       }
  742.       else {
  743. if (k != unterblossomliste[lit2].basis) {
  744.   rek_erweitere
  745.     (G, gematcht, unterblossomliste, unterblossomliste[lit2], k);
  746.   aktualisiere_knotenliste
  747.     (unterblossomliste, unterblossomliste[lit2]);
  748. }
  749.       }
  750.     }
  751.     else if ((!unterblossomliste[lit].knotenliste.empty()) &&
  752.       (unterblossomliste[lit2].knotenliste.empty())) {
  753.       if (k == unterblossomliste[lit2].basis) {
  754. if (l != unterblossomliste[lit].basis) {
  755.   rek_erweitere
  756.     (G, gematcht, unterblossomliste, unterblossomliste[lit], l);
  757.   aktualisiere_knotenliste
  758.     (unterblossomliste, unterblossomliste[lit]);
  759. }
  760.       }
  761.       else {
  762. if (k != unterblossomliste[lit].basis) {
  763.   rek_erweitere
  764.     (G, gematcht, unterblossomliste, unterblossomliste[lit], k);
  765.   aktualisiere_knotenliste
  766.     (unterblossomliste, unterblossomliste[lit]);
  767. }
  768.       }
  769.     }
  770.   }
  771. }
  772. void aktualisiere_knotenliste
  773.  (list <blossom > &unterblossomliste, blossom & bl) {
  774.   bl.knotenliste.clear();
  775.   if (!bl.ub_zeiger_liste.empty()) {
  776.     list_item ubzlit = bl.ub_zeiger_liste.first();
  777.     while (ubzlit != nil) {
  778.       list_item ubllit = bl.ub_zeiger_liste[ubzlit];
  779.       if (!unterblossomliste[ubllit].knotenliste.empty()) {
  780. list_item knotenlit = unterblossomliste[ubllit].knotenliste.first();
  781. while (knotenlit != nil) {
  782.   node i = unterblossomliste[ubllit].knotenliste.inf(knotenlit);
  783.   bl.knotenliste.append(i);
  784.   knotenlit = unterblossomliste[ubllit].knotenliste.succ(knotenlit);
  785. }
  786.       }
  787.       else {
  788. bl.knotenliste.append(unterblossomliste[ubllit].basis);
  789.       }
  790.       ubzlit = bl.ub_zeiger_liste.succ(ubzlit);
  791.     }
  792.   }
  793. }
  794. void bilde_blossom
  795.  (const ugraph &G,
  796.    const edge_array <GEWICHT_TYP > &gewicht,
  797.    const node_array <DUALER_TYP > &u,
  798.    const edge_array <bool >&gematcht,
  799.    const list <edge >&pfad,
  800.    list <blossom > &blossomliste,
  801.    list <blossom > &unterblossomliste,
  802.    list <node >&ungescannt,
  803.    node_array <list_item >&blossom_zu_knoten,
  804.    node_array <KANTENLISTE > &brauchbare_kanten,
  805.    node_array <edge >&d2_kante) {
  806.   node neue_basis;
  807.   list_item neues_blossom;
  808.   list <list_item >zliste;
  809.   list <node >nliste;
  810.   edge hilfskante;
  811.   edge e1 = pfad.inf(pfad.first());
  812.   edge e2 = pfad.inf(pfad.last());
  813.   node i1 = G.source(e1);
  814.   node i2 = G.target(e1);
  815.   node i3 = G.source(e2);
  816.   node i4 = G.target(e2);
  817.   if ((blossom_zu_knoten[i1] == blossom_zu_knoten[i3]) ||
  818.     (blossom_zu_knoten[i1] == blossom_zu_knoten[i4])) {
  819.     neue_basis = blossomliste[blossom_zu_knoten[i1]].basis;
  820.   }
  821.   else
  822.     neue_basis = blossomliste[blossom_zu_knoten[i2]].basis;
  823.   list_item litpfad = pfad.first();
  824.   while (pfad.succ(litpfad) != nil) {
  825.     list_item bllit;
  826.     edge e1 = pfad.inf(litpfad);
  827.     edge e2 = pfad.inf(pfad.succ(litpfad));
  828.     node i1 = G.source(e1);
  829.     node i2 = G.target(e1);
  830.     node i3 = G.source(e2);
  831.     node i4 = G.target(e2);
  832.     if ((blossom_zu_knoten[i1] == blossom_zu_knoten[i3]) ||
  833.       (blossom_zu_knoten[i1] == blossom_zu_knoten[i4])) {
  834.       bllit = blossom_zu_knoten[i1];
  835.     }
  836.     else
  837.       bllit = blossom_zu_knoten[i2];
  838.     if (!blossomliste[bllit].knotenliste.empty()) {
  839.       list_item knotenlit = blossomliste[bllit].knotenliste.first();
  840.       while (knotenlit != nil) {
  841. node i = blossomliste[bllit].knotenliste[knotenlit];
  842. nliste.append(i);
  843. knotenlit = blossomliste[bllit].knotenliste.succ(knotenlit);
  844.       }
  845.     }
  846.     else {
  847.       node i = blossomliste[bllit].basis;
  848.       nliste.append(i);
  849.     }
  850.     if (blossomliste[bllit].typ == T) {
  851.       neues_s_blossom(G, gewicht, u, blossomliste, blossom_zu_knoten, gematcht,
  852. blossomliste[bllit], ungescannt, brauchbare_kanten, d2_kante);
  853.     }
  854.     blossom bl = blossomliste.del_item(bllit);
  855.     bllit = unterblossomliste.append(bl);
  856.     unterblossomliste[bllit].typ = UNMARKIERT;
  857.     unterblossomliste[bllit].kante = nil;
  858.     zliste.append(bllit);
  859.     litpfad = pfad.succ(litpfad);
  860.   }
  861.   list_item bllit = blossom_zu_knoten[neue_basis];
  862.   blossom bl = blossomliste.del_item(bllit);
  863.   hilfskante = bl.kante;
  864.   bllit = unterblossomliste.append(bl);
  865.   unterblossomliste[bllit].typ = UNMARKIERT;
  866.   unterblossomliste[bllit].kante = nil;
  867.   zliste.append(bllit);
  868.   if (!bl.knotenliste.empty()) {
  869.     list_item lit = bl.knotenliste.first();
  870.     while (lit != nil) {
  871.       nliste.append(bl.knotenliste.inf(lit));
  872.       lit = bl.knotenliste.succ(lit);
  873.     }
  874.   }
  875.   else
  876.     nliste.append(bl.basis);
  877.   bl = blossom(zliste, pfad, nliste, neue_basis);
  878.   bl.typ = S;
  879.   bl.kante = hilfskante;
  880.   neues_blossom = blossomliste.append(bl);
  881.   list_item litn = nliste.first();
  882.   while (litn != nil) {
  883.     node i = nliste[litn];
  884.     blossom_zu_knoten[i] = neues_blossom;
  885.     litn = nliste.succ(litn);
  886.   }
  887.   if (!blossomliste[neues_blossom].ub_zeiger_liste.empty()) {
  888.     list_item ubzlit = blossomliste[neues_blossom].ub_zeiger_liste.first();
  889.     while (ubzlit != nil) {
  890.       list_item ubllit = blossomliste[neues_blossom].ub_zeiger_liste[ubzlit];
  891.       if (unterblossomliste[ubllit].d3_kante != nil) {
  892. edge e = unterblossomliste[ubllit].d3_kante;
  893. node i = G.source(e);
  894. node j = G.target(e);
  895. DUALER_TYP pi = u[G.source(e)] + u[G.target(e)] - gewicht[e];
  896. if ((blossom_zu_knoten[i] == blossom_zu_knoten[j]) ||
  897.   (pi == 0) || (pi < 0 && (-pi) < GENAUIGKEIT) || (pi > 0 && pi < GENAUIGKEIT)) {
  898.   unterblossomliste[ubllit].d3_kante = nil;
  899.   list <list_item >loesche_kante;
  900.   if (!unterblossomliste[ubllit].adj_s_blossoms.empty()) {
  901.     list_item kantenlit = unterblossomliste[ubllit].adj_s_blossoms.first();
  902.     while (kantenlit != nil) {
  903.       edge e = unterblossomliste[ubllit].adj_s_blossoms[kantenlit];
  904.       DUALER_TYP pi = u[G.source(e)] + u[G.target(e)] - gewicht[e];
  905.       if ((blossom_zu_knoten[G.source(e)] != blossom_zu_knoten[G.target(e)]) &&
  906. (pi > GENAUIGKEIT || pi < -GENAUIGKEIT)) {
  907. if (unterblossomliste[ubllit].d3_kante == nil)
  908.   unterblossomliste[ubllit].d3_kante = e;
  909. else {
  910.   edge e_min = unterblossomliste[ubllit].d3_kante;
  911.   DUALER_TYP pi_min = u[G.source(e_min)] + u[G.target(e_min)] - gewicht[e_min];
  912.   if (pi < pi_min)
  913.     unterblossomliste[ubllit].d3_kante = e;
  914. }
  915.       }
  916.       else
  917. loesche_kante.append(kantenlit);
  918.       kantenlit = unterblossomliste[ubllit].adj_s_blossoms.succ(kantenlit);
  919.     }
  920.   }
  921.   while (!loesche_kante.empty()) {
  922.     list_item lit = loesche_kante.pop();
  923.     blossomliste[ubllit].adj_s_blossoms.del_item(lit);
  924.   }
  925. }
  926.       }
  927.       ubzlit = blossomliste[neues_blossom].ub_zeiger_liste.succ(ubzlit);
  928.     }
  929.   }
  930.   if (!blossomliste[neues_blossom].ub_zeiger_liste.empty()) {
  931.     list_item ubzlit = blossomliste[neues_blossom].ub_zeiger_liste.first();
  932.     while (ubzlit != nil) {
  933.       list_item ubllit = blossomliste[neues_blossom].ub_zeiger_liste[ubzlit];
  934.       if (unterblossomliste[ubllit].d3_kante != nil) {
  935. edge e = unterblossomliste[ubllit].d3_kante;
  936. DUALER_TYP pi_e = u[G.source(e)] + u[G.target(e)] - gewicht[e];
  937. if (blossomliste[neues_blossom].d3_kante == nil)
  938.   blossomliste[neues_blossom].d3_kante = e;
  939. else {
  940.   edge e_min = blossomliste[neues_blossom].d3_kante;
  941.   DUALER_TYP pi_min;
  942.   pi_min = u[G.source(e_min)] + u[G.target(e_min)] - gewicht[e_min];
  943.   if (pi_e < pi_min)
  944.     blossomliste[neues_blossom].d3_kante = e;
  945. }
  946. blossomliste[neues_blossom].adj_s_blossoms.append(e);
  947. unterblossomliste[ubllit].d3_kante = nil;
  948.       }
  949.       unterblossomliste[ubllit].adj_s_blossoms.clear();
  950.       ubzlit = blossomliste[neues_blossom].ub_zeiger_liste.succ(ubzlit);
  951.     }
  952.   }
  953. }
  954. int aendere_duale_variablen
  955.  (const ugraph &G, const edge_array <GEWICHT_TYP > &gewicht,
  956.    const edge_array <bool >&gematcht,
  957.    const node_array <list_item >&blossom_zu_knoten,
  958.    const node_array <edge >&gematchte_kante,
  959.    list <blossom > &blossomliste,
  960.    node_array <DUALER_TYP > &u,
  961.    list <node >&ungescannt,
  962.    node_array <KANTENLISTE > &brauchbare_kanten,
  963.    const node_array <edge >&d2_kante) {
  964.   DUALER_TYP delta, d_1, d_2, d_3, d_4;
  965.   int erg_aendere;
  966.   node_array <bool >schon_eingefuegt;
  967.   schon_eingefuegt.init(G, false);
  968.   d_1 = 0;
  969.   d_2 = 0;
  970.   node i;
  971.   forall_nodes (i, G) {
  972.     if (gematchte_kante[i] == nil) {
  973.       d_1 = u[i];
  974.     }
  975.     list_item bllit = blossom_zu_knoten[i];
  976.     if ((blossomliste[bllit].typ == UNMARKIERT) && (d2_kante[i] != nil)) {
  977.       edge e = d2_kante[i];
  978.       DUALER_TYP pi = u[G.source(e)] + u[G.target(e)] - gewicht[e];
  979.       if ((d_2 == 0) || (pi < d_2)) {
  980. d_2 = pi;
  981.       }
  982.     }
  983.   }
  984.   if (d_2 == 0)
  985.     d_2 = d_1;
  986.   d_3 = d_1;
  987.   d_4 = 2 * d_1;
  988.   if (!blossomliste.empty()) {
  989.     list_item bllit = blossomliste.first();
  990.     while (bllit != nil) {
  991.       if ((blossomliste[bllit].typ == S) && (blossomliste[bllit].d3_kante != nil)) {
  992. edge e = blossomliste[bllit].d3_kante;
  993. DUALER_TYP pi = (u[G.source(e)] + u[G.target(e)] - gewicht[e]) / 2;
  994. if (pi < d_3)
  995.   d_3 = pi;
  996.       }
  997.       else if ((!blossomliste[bllit].knotenliste.empty()) &&
  998. (blossomliste[bllit].typ == T)) {
  999. if (blossomliste[bllit].z < d_4) {
  1000.   d_4 = blossomliste[bllit].z;
  1001. }
  1002.       }
  1003.       bllit = blossomliste.succ(bllit);
  1004.     }
  1005.   }
  1006.   d_4 = d_4 / 2;
  1007.   if ((d_1 <= d_2) && (d_1 <= d_3) && (d_1 <= d_4)) {
  1008.     delta = d_1;
  1009.     erg_aendere = 1;
  1010.   }
  1011.   else if ((d_2 <= d_3) && (d_2 <= d_4)) {
  1012.     delta = d_2;
  1013.     erg_aendere = 0;
  1014.   }
  1015.   else if (d_3 <= d_4) {
  1016.     delta = d_3;
  1017.     erg_aendere = 0;
  1018.   }
  1019.   else {
  1020.     delta = d_4;
  1021.     erg_aendere = -1;
  1022.   }
  1023.   forall_nodes (i, G) {
  1024.     if (blossomliste[blossom_zu_knoten[i]].typ == S) {
  1025.       u[i] = u[i] - delta;
  1026.     }
  1027.     if (blossomliste[blossom_zu_knoten[i]].typ == T) {
  1028.       u[i] = u[i] + delta;
  1029.     }
  1030.   }
  1031.   if (!blossomliste.empty()) {
  1032.     list_item bllit = blossomliste.first();
  1033.     while (bllit != nil) {
  1034.       if (!blossomliste[bllit].knotenliste.empty()) {
  1035. if (blossomliste[bllit].typ == S) {
  1036.   blossomliste[bllit].z = blossomliste[bllit].z + 2 * delta;
  1037. }
  1038. else if (blossomliste[bllit].typ == T) {
  1039.   blossomliste[bllit].z = blossomliste[bllit].z - 2 * delta;
  1040. }
  1041.       }
  1042.       bllit = blossomliste.succ(bllit);
  1043.     }
  1044.   }
  1045.   if (delta == d_1)
  1046.     return erg_aendere;
  1047.   forall_nodes (i, G) {
  1048.     if ((blossomliste[blossom_zu_knoten[i]].typ == UNMARKIERT) &&
  1049.       (d2_kante[i] != nil)) {
  1050.       edge e = d2_kante[i];
  1051.       node j;
  1052.       if (i == G.target(e))
  1053. j = G.source(e);
  1054.       else
  1055. j = G.target(e);
  1056.       DUALER_TYP pi = u[i] + u[j] - gewicht[e];
  1057.       if ((pi == 0) ||
  1058. ((pi < 0) && ((-pi) < GENAUIGKEIT)) ||
  1059. ((pi > 0) && (pi < GENAUIGKEIT))) {
  1060. brauchbare_kanten[j].append(e);
  1061. if (schon_eingefuegt[j] == false) {
  1062.   ungescannt.push(j);
  1063.   schon_eingefuegt[j] = true;
  1064. }
  1065.       }
  1066.     }
  1067.   }
  1068.   if (!blossomliste.empty()) {
  1069.     edge_array <bool >kante_schon_betrachtet(G, false);
  1070.     list_item bllit = blossomliste.first();
  1071.     while (bllit != nil) {
  1072.       if ((blossomliste[bllit].typ == S) && (blossomliste[bllit].d3_kante != nil)) {
  1073. edge e = blossomliste[bllit].d3_kante;
  1074. DUALER_TYP pi = u[G.source(e)] + u[G.target(e)] - gewicht[e];
  1075. if ((pi == 0) ||
  1076.   ((pi < 0) && ((-pi) < GENAUIGKEIT)) ||
  1077.   ((pi > 0) && (pi < GENAUIGKEIT))) {
  1078.   if (schon_eingefuegt[G.source(e)] == false) {
  1079.     ungescannt.push(G.source(e));
  1080.     schon_eingefuegt[G.source(e)] = true;
  1081.   }
  1082.   if (schon_eingefuegt[G.target(e)] == false) {
  1083.     ungescannt.push(G.target(e));
  1084.     schon_eingefuegt[G.target(e)] = true;
  1085.   }
  1086.   if (kante_schon_betrachtet[e] == false) {
  1087.     brauchbare_kanten[G.source(e)].append(e);
  1088.     brauchbare_kanten[G.target(e)].append(e);
  1089.     kante_schon_betrachtet[e] = true;
  1090.   }
  1091. }
  1092.       }
  1093.       bllit = blossomliste.succ(bllit);
  1094.     }
  1095.   }
  1096.   return erg_aendere;
  1097. }
  1098. ;
  1099. void expandiere_blossoms(
  1100.    const ugraph &G,
  1101.    const edge_array <GEWICHT_TYP > &gewicht,
  1102.    const node_array <DUALER_TYP > &u,
  1103.    const edge_array <bool >&gematcht,
  1104.    list <blossom > &blossomliste,
  1105.    list <blossom > &unterblossomliste,
  1106.    list <node >&ungescannt,
  1107.    node_array <list_item >&blossom_zu_knoten,
  1108.    node_array <KANTENLISTE > &brauchbare_kanten,
  1109.    node_array <edge >&d2_kante)
  1110. {
  1111.   list <list_item >entferne_liste, verschiebe_liste;
  1112.   list_item bllit = blossomliste.first();
  1113.   while (bllit != nil) {
  1114.     if ((!blossomliste[bllit].knotenliste.empty()) &&
  1115.       (blossomliste[bllit].typ == T) && (blossomliste[bllit].z == 0)) {
  1116.       edge e = blossomliste[bllit].kante;
  1117.       node i;
  1118.       if (blossom_zu_knoten[G.source(e)] == bllit)
  1119. i = G.source(e);
  1120.       else if (blossom_zu_knoten[G.target(e)] == bllit)
  1121. i = G.target(e);
  1122.       list_item knotenlit = blossomliste[bllit].knotenliste.first();
  1123.       node j = blossomliste[bllit].knotenliste.inf(knotenlit);
  1124.       list_item ubzlit = blossomliste[bllit].ub_zeiger_liste.first();
  1125.       list_item ubllit = blossomliste[bllit].ub_zeiger_liste.inf(ubzlit);
  1126.       list_item kantenlit = blossomliste[bllit].kantenliste.first();
  1127.       while (i != j) {
  1128. if (j == unterblossomliste[ubllit].basis) {
  1129.   ubzlit = blossomliste[bllit].ub_zeiger_liste.succ(ubzlit);
  1130.   ubllit = blossomliste[bllit].ub_zeiger_liste.inf(ubzlit);
  1131.   kantenlit = blossomliste[bllit].kantenliste.succ(kantenlit);
  1132. }
  1133. knotenlit = blossomliste[bllit].knotenliste.succ(knotenlit);
  1134. j = blossomliste[bllit].knotenliste.inf(knotenlit);
  1135.       }
  1136.       unterblossomliste[ubllit].typ = T;
  1137.       unterblossomliste[ubllit].kante = e;
  1138.       e = blossomliste[bllit].kantenliste.inf(kantenlit);
  1139.       if (gematcht[e] == true) {
  1140. list_item ubzlit_kopie = ubzlit;
  1141. list_item kantenlit_kopie = kantenlit;
  1142. ubzlit = blossomliste[bllit].ub_zeiger_liste.pred(ubzlit);
  1143. while (ubzlit != nil) {
  1144.   e = blossomliste[bllit].kantenliste.inf(kantenlit);
  1145.   ubllit = blossomliste[bllit].ub_zeiger_liste.inf(ubzlit);
  1146.   if (gematcht[e] == true) {
  1147.     unterblossomliste[ubllit].typ = S;
  1148.     unterblossomliste[ubllit].kante = e;
  1149.   }
  1150.   else {
  1151.     unterblossomliste[ubllit].typ = T;
  1152.     unterblossomliste[ubllit].kante = e;
  1153.   }
  1154.   kantenlit = blossomliste[bllit].kantenliste.pred(kantenlit);
  1155.   ubzlit = blossomliste[bllit].ub_zeiger_liste.pred(ubzlit);
  1156. }
  1157. ubzlit = blossomliste[bllit].ub_zeiger_liste.last();
  1158. ubllit = blossomliste[bllit].ub_zeiger_liste[ubzlit];
  1159. e = blossomliste[bllit].kantenliste.inf(kantenlit);
  1160. unterblossomliste[ubllit].typ = T;
  1161. unterblossomliste[ubllit].kante = e;
  1162. ubzlit = ubzlit_kopie;
  1163. kantenlit = kantenlit_kopie;
  1164. ubzlit = blossomliste[bllit].ub_zeiger_liste.succ(ubzlit);
  1165. kantenlit = blossomliste[bllit].kantenliste.succ(kantenlit);
  1166. kantenlit = blossomliste[bllit].kantenliste.succ(kantenlit);
  1167. while (kantenlit != nil) {
  1168.   e = blossomliste[bllit].kantenliste[kantenlit];
  1169.   list_item ubllit = blossomliste[bllit].ub_zeiger_liste[ubzlit];
  1170.   list_item ubzlit_succ = blossomliste[bllit].ub_zeiger_liste.succ(ubzlit);
  1171.   list_item ubllit_succ = blossomliste[bllit].ub_zeiger_liste[ubzlit_succ];
  1172.   if (!unterblossomliste[ubllit].knotenliste.empty()) {
  1173.     list_item knotenlit = unterblossomliste[ubllit].knotenliste.first();
  1174.     while ((knotenlit != nil) && (unterblossomliste[ubllit].typ == UNMARKIERT)) {
  1175.       node i = unterblossomliste[ubllit].knotenliste[knotenlit];
  1176.       if (!brauchbare_kanten[i].empty()) {
  1177. edge e_brauchbar = brauchbare_kanten[i].pop();
  1178. unterblossomliste[ubllit].typ = T;
  1179. unterblossomliste[ubllit].kante = e_brauchbar;
  1180. unterblossomliste[ubllit_succ].typ = S;
  1181. unterblossomliste[ubllit_succ].kante = e;
  1182.       }
  1183.       knotenlit = unterblossomliste[ubllit].knotenliste.succ(knotenlit);
  1184.     }
  1185.   }
  1186.   else {
  1187.     node i = unterblossomliste[ubllit].basis;
  1188.     if (!brauchbare_kanten[i].empty()) {
  1189.       edge e_brauchbar = brauchbare_kanten[i].pop();
  1190.       unterblossomliste[ubllit].typ = T;
  1191.       unterblossomliste[ubllit].kante = e_brauchbar;
  1192.       unterblossomliste[ubllit_succ].typ = S;
  1193.       unterblossomliste[ubllit_succ].kante = e;
  1194.     }
  1195.   }
  1196.   if (!unterblossomliste[ubllit_succ].knotenliste.empty()) {
  1197.     list_item knotenlit = unterblossomliste[ubllit_succ].knotenliste.first();
  1198.     while ((knotenlit != nil) &&
  1199.       (unterblossomliste[ubllit_succ].typ == UNMARKIERT)) {
  1200.       node i = unterblossomliste[ubllit_succ].knotenliste[knotenlit];
  1201.       if (!brauchbare_kanten[i].empty()) {
  1202. edge e_brauchbar = brauchbare_kanten[i].pop();
  1203. unterblossomliste[ubllit_succ].typ = T;
  1204. unterblossomliste[ubllit_succ].kante = e_brauchbar;
  1205. unterblossomliste[ubllit].typ = S;
  1206. unterblossomliste[ubllit].kante = e;
  1207.       }
  1208.       knotenlit = unterblossomliste[ubllit_succ].knotenliste.succ(knotenlit);
  1209.     }
  1210.   }
  1211.   else {
  1212.     node i = unterblossomliste[ubllit_succ].basis;
  1213.     if (!brauchbare_kanten[i].empty()) {
  1214.       edge e_brauchbar = brauchbare_kanten[i].pop();
  1215.       unterblossomliste[ubllit_succ].typ = T;
  1216.       unterblossomliste[ubllit_succ].kante = e_brauchbar;
  1217.       unterblossomliste[ubllit].typ = S;
  1218.       unterblossomliste[ubllit].kante = e;
  1219.     }
  1220.   }
  1221.   ubzlit = blossomliste[bllit].ub_zeiger_liste.succ(ubzlit);
  1222.   ubzlit = blossomliste[bllit].ub_zeiger_liste.succ(ubzlit);
  1223.   kantenlit = blossomliste[bllit].kantenliste.succ(kantenlit);
  1224.   kantenlit = blossomliste[bllit].kantenliste.succ(kantenlit);
  1225. }
  1226.       }
  1227.       else if (gematcht[e] != true) {
  1228. list_item ubzlit_kopie = ubzlit;
  1229. list_item kantenlit_kopie = kantenlit;
  1230. kantenlit = blossomliste[bllit].kantenliste.succ(kantenlit);
  1231. ubzlit = blossomliste[bllit].ub_zeiger_liste.succ(ubzlit);
  1232. while (kantenlit != nil) {
  1233.   e = blossomliste[bllit].kantenliste.inf(kantenlit);
  1234.   ubllit = blossomliste[bllit].ub_zeiger_liste.inf(ubzlit);
  1235.   if (gematcht[e] == true) {
  1236.     unterblossomliste[ubllit].typ = S;
  1237.     unterblossomliste[ubllit].kante = e;
  1238.   }
  1239.   else {
  1240.     unterblossomliste[ubllit].typ = T;
  1241.     unterblossomliste[ubllit].kante = e;
  1242.   }
  1243.   kantenlit = blossomliste[bllit].kantenliste.succ(kantenlit);
  1244.   ubzlit = blossomliste[bllit].ub_zeiger_liste.succ(ubzlit);
  1245. }
  1246. ubzlit = ubzlit_kopie;
  1247. kantenlit = kantenlit_kopie;
  1248. ubzlit = blossomliste[bllit].ub_zeiger_liste.pred(ubzlit);
  1249. kantenlit = blossomliste[bllit].kantenliste.pred(kantenlit);
  1250. while (kantenlit != nil) {
  1251.   e = blossomliste[bllit].kantenliste[kantenlit];
  1252.   list_item ubllit = blossomliste[bllit].ub_zeiger_liste[ubzlit];
  1253.   list_item ubzlit_pred = blossomliste[bllit].ub_zeiger_liste.pred(ubzlit);
  1254.   list_item ubllit_pred = blossomliste[bllit].ub_zeiger_liste[ubzlit_pred];
  1255.   if (!unterblossomliste[ubllit].knotenliste.empty()) {
  1256.     list_item knotenlit = unterblossomliste[ubllit].knotenliste.first();
  1257.     while ((knotenlit != nil) && (unterblossomliste[ubllit].typ == UNMARKIERT)) {
  1258.       node i = unterblossomliste[ubllit].knotenliste[knotenlit];
  1259.       if (!brauchbare_kanten[i].empty()) {
  1260. edge e_brauchbar = brauchbare_kanten[i].pop();
  1261. unterblossomliste[ubllit].typ = T;
  1262. unterblossomliste[ubllit].kante = e_brauchbar;
  1263. unterblossomliste[ubllit_pred].typ = S;
  1264. unterblossomliste[ubllit_pred].kante = e;
  1265.       }
  1266.       knotenlit = unterblossomliste[ubllit].knotenliste.succ(knotenlit);
  1267.     }
  1268.   }
  1269.   else {
  1270.     node i = unterblossomliste[ubllit].basis;
  1271.     if (!brauchbare_kanten[i].empty()) {
  1272.       edge e_brauchbar = brauchbare_kanten[i].pop();
  1273.       unterblossomliste[ubllit].typ = T;
  1274.       unterblossomliste[ubllit].kante = e_brauchbar;
  1275.       unterblossomliste[ubllit_pred].typ = S;
  1276.       unterblossomliste[ubllit_pred].kante = e;
  1277.     }
  1278.   }
  1279.   if (!unterblossomliste[ubllit_pred].knotenliste.empty()) {
  1280.     list_item knotenlit = unterblossomliste[ubllit_pred].knotenliste.first();
  1281.     while ((knotenlit != nil) &&
  1282.       (unterblossomliste[ubllit_pred].typ == UNMARKIERT)) {
  1283.       node i = unterblossomliste[ubllit_pred].knotenliste[knotenlit];
  1284.       if (!brauchbare_kanten[i].empty()) {
  1285. edge e_brauchbar = brauchbare_kanten[i].pop();
  1286. unterblossomliste[ubllit_pred].typ = T;
  1287. unterblossomliste[ubllit_pred].kante = e_brauchbar;
  1288. unterblossomliste[ubllit].typ = S;
  1289. unterblossomliste[ubllit].kante = e;
  1290.       }
  1291.       knotenlit = unterblossomliste[ubllit_pred].knotenliste.succ(knotenlit);
  1292.     }
  1293.   }
  1294.   else {
  1295.     node i = unterblossomliste[ubllit_pred].basis;
  1296.     if (!brauchbare_kanten[i].empty()) {
  1297.       edge e_brauchbar = brauchbare_kanten[i].pop();
  1298.       unterblossomliste[ubllit_pred].typ = T;
  1299.       unterblossomliste[ubllit_pred].kante = e_brauchbar;
  1300.       unterblossomliste[ubllit].typ = S;
  1301.       unterblossomliste[ubllit].kante = e;
  1302.     }
  1303.   }
  1304.   ubzlit = blossomliste[bllit].ub_zeiger_liste.pred(ubzlit);
  1305.   ubzlit = blossomliste[bllit].ub_zeiger_liste.pred(ubzlit);
  1306.   kantenlit = blossomliste[bllit].kantenliste.pred(kantenlit);
  1307.   kantenlit = blossomliste[bllit].kantenliste.pred(kantenlit);
  1308. }
  1309.       }
  1310.       ubzlit = blossomliste[bllit].ub_zeiger_liste.first();
  1311.       while (ubzlit != nil) {
  1312. ubllit = blossomliste[bllit].ub_zeiger_liste.inf(ubzlit);
  1313. verschiebe_liste.append(ubllit);
  1314. ubzlit = blossomliste[bllit].ub_zeiger_liste.succ(ubzlit);
  1315.       }
  1316.       entferne_liste.append(bllit);
  1317.     }
  1318.     bllit = blossomliste.succ(bllit);
  1319.   }
  1320.   while (!entferne_liste.empty()) {
  1321.     blossomliste.del_item(entferne_liste.pop());
  1322.   }
  1323.   if (!verschiebe_liste.empty()) {
  1324.     list_item vlit = verschiebe_liste.first();
  1325.     list_item ubllit;
  1326.     while (vlit != nil) {
  1327.       ubllit = verschiebe_liste.inf(vlit);
  1328.       list_item hilfslit = blossomliste.append(unterblossomliste[ubllit]);
  1329.       unterblossomliste.del_item(verschiebe_liste.inf(vlit));
  1330.       if (!blossomliste[hilfslit].knotenliste.empty()) {
  1331. list_item knotenlit = blossomliste[hilfslit].knotenliste.first();
  1332. while (knotenlit != nil) {
  1333.   node i = blossomliste[hilfslit].knotenliste[knotenlit];
  1334.   blossom_zu_knoten[i] = hilfslit;
  1335.   knotenlit = blossomliste[hilfslit].knotenliste.succ(knotenlit);
  1336. }
  1337.       }
  1338.       else {
  1339. node i = blossomliste[hilfslit].basis;
  1340. blossom_zu_knoten[i] = hilfslit;
  1341.       }
  1342.       vlit = verschiebe_liste.succ(vlit);
  1343.     }
  1344.   }
  1345.   if (!verschiebe_liste.empty()) {
  1346.     list_item vlit = verschiebe_liste.first();
  1347.     list_item hilfslit = blossomliste.last();
  1348.     while (vlit != nil) {
  1349.       if (blossomliste[hilfslit].typ == S) {
  1350. neues_s_blossom
  1351.   (G, gewicht, u, blossomliste, blossom_zu_knoten, gematcht,
  1352.   blossomliste[hilfslit], ungescannt, brauchbare_kanten, d2_kante);
  1353.       }
  1354.       hilfslit = blossomliste.pred(hilfslit);
  1355.       vlit = verschiebe_liste.succ(vlit);
  1356.     }
  1357.   }
  1358. }
  1359. void matchingtest(const ugraph &G, const edge_array <bool >&gematcht)
  1360. {
  1361.   node_array <bool >knoten_betrachtet(G, false);
  1362.   edge e;
  1363.   forall_edges (e, G) {
  1364.     node i = G.source(e);
  1365.     node j = G.target(e);
  1366.     if (gematcht[e] == true) {
  1367.       if (knoten_betrachtet[i] == false)
  1368. knoten_betrachtet[i] = true;
  1369.       else {
  1370. cout << "Knoten ";
  1371. G.print_node(i);
  1372. cout << " ist Endknoten mehrerer gematchter Kanten!!!n";
  1373.       }
  1374.       if (knoten_betrachtet[j] == false)
  1375. knoten_betrachtet[j] = true;
  1376.       else {
  1377. cout << "Knoten ";
  1378. G.print_node(j);
  1379. cout << " ist Endknoten mehrerer gematchter Kanten!!!n";
  1380.       }
  1381.     }
  1382.   }
  1383.   cout << "Test auf Matching abgeschlossen!n";
  1384.   return;
  1385. }
  1386. void bed1test(const ugraph &G, const edge_array <GEWICHT_TYP > &gewicht, const
  1387.    node_array <DUALER_TYP > &u, const list <blossom > &blossomliste, const
  1388.    list <blossom > &unterblossomliste, const node_array <list_item >&blossom_zu_knoten)
  1389. {
  1390.   node i;
  1391.   forall_nodes (i, G) {
  1392.     if (u[i] < 0) {
  1393.       cout << "Die duale Variable von Knoten ";
  1394.       G.print_node(i);
  1395.       cout << " ist negativn";
  1396.     }
  1397.   }
  1398.   edge e;
  1399.   forall_edges (e, G) {
  1400.     node i = G.source(e);
  1401.     node j = G.target(e);
  1402.     list_item litsource = blossom_zu_knoten[i];
  1403.     list_item littarget = blossom_zu_knoten[j];
  1404.     DUALER_TYP z;
  1405.     if (litsource != littarget)
  1406.       z = 0;
  1407.     else
  1408.       z = bestimme_z(G, blossomliste, unterblossomliste, blossomliste[litsource], e);
  1409.     DUALER_TYP pi = u[i] + u[j] - gewicht[e] + z;
  1410.     if (pi < 0) {
  1411.       cout << "pi<0 fuer Kante ";
  1412.       G.print_edge(e);
  1413.       cout << endl;
  1414.     }
  1415.   }
  1416.   if (!blossomliste.empty()) {
  1417.     list_item lit = blossomliste.first();
  1418.     while (lit != nil) {
  1419.       if (blossomliste[lit].z < 0) {
  1420. cout << "Es gibt ein z<0n";
  1421.       }
  1422.       lit = blossomliste.succ(lit);
  1423.     }
  1424.   }
  1425.   if (!unterblossomliste.empty()) {
  1426.     list_item lit = unterblossomliste.first();
  1427.     while (lit != nil) {
  1428.       if (unterblossomliste[lit].z < 0) {
  1429. cout << "Es gibt ein z<0n";
  1430.       }
  1431.       lit = unterblossomliste.succ(lit);
  1432.     }
  1433.   }
  1434.   cout << "Test von Bedingung (1) abgeschlossen!n";
  1435.   return;
  1436. }
  1437. void bed2test(const ugraph &G, const edge_array <GEWICHT_TYP > &gewicht, const
  1438.    list <blossom > &blossomliste, const list <blossom > &unterblossomliste, const
  1439.    node_array <list_item >&blossom_zu_knoten, const edge_array <bool >&gematcht,
  1440.    const node_array <DUALER_TYP > &u)
  1441. {
  1442.   edge e;
  1443.   forall_edges (e, G) {
  1444.     if (gematcht[e] == true) {
  1445.       node i = G.source(e);
  1446.       node j = G.target(e);
  1447.       list_item litsource = blossom_zu_knoten[i];
  1448.       list_item littarget = blossom_zu_knoten[j];
  1449.       DUALER_TYP z;
  1450.       if (litsource != littarget)
  1451. z = 0;
  1452.       else
  1453. z = bestimme_z(G, blossomliste, unterblossomliste, blossomliste[litsource], e);
  1454.       DUALER_TYP pi = u[i] + u[j] - gewicht[e] + z;
  1455.       if (pi > 0) {
  1456. cout << "Kante ";
  1457. G.print_edge(e);
  1458. cout << " ist gematcht, aber pi ist positivn";
  1459.       }
  1460.     }
  1461.   }
  1462.   cout << "Test von Bedingung (2) abgeschlossen!n";
  1463.   return;
  1464. }
  1465. void bed3test(const ugraph &G, const node_array <DUALER_TYP > &u, const
  1466.    node_array <edge >&gematchte_kante)
  1467. {
  1468.   node i;
  1469.   forall_nodes (i, G) {
  1470.     if (u[i] > 0) {
  1471.       if (gematchte_kante[i] == nil) {
  1472. cout << "Die duale Variable des freien Knotens ";
  1473. G.print_node(i);
  1474. cout << " ist positivn";
  1475.       }
  1476.     }
  1477.   }
  1478.   cout << "Test von Bedingung (3) abgeschlossen!n";
  1479.   return;
  1480. }
  1481. void bed4test(const ugraph &G, const list <blossom > &blossomliste, const
  1482.    list <blossom > &unterblossomliste, const node_array <edge >&gematchte_kante,
  1483.    const node_array <list_item >&blossom_zu_knoten)
  1484. {
  1485.   if (!blossomliste.empty()) {
  1486.     list_item lit = blossomliste.first();
  1487.     while (lit != nil) {
  1488.       node_array <bool >schon_besucht(G, false);
  1489.       int anzknoten = 0;
  1490.       int anzgematchtekanten = 0;
  1491.       if ((blossomliste[lit].z > 0) &&
  1492. (!blossomliste[lit].knotenliste.empty())) {
  1493. list_item knotenlit = blossomliste[lit].knotenliste.first();
  1494. while (knotenlit != nil) {
  1495.   anzknoten++;
  1496.   node v = blossomliste[lit].knotenliste[knotenlit];
  1497.   if ((!schon_besucht[v]) && (gematchte_kante[v] != nil)) {
  1498.     schon_besucht[v] = true;
  1499.     edge e = gematchte_kante[v];
  1500.     node w = G.opposite(v, e);
  1501.     if (blossom_zu_knoten[w] == lit) {
  1502.       anzgematchtekanten++;
  1503.       schon_besucht[w] = true;
  1504.     }
  1505.   }
  1506.   knotenlit = blossomliste[lit].knotenliste.succ(knotenlit);
  1507. }
  1508. if (anzknoten != (2 * anzgematchtekanten + 1)) {
  1509.   cout << "Bedingung (4) ist verletzt!!!n";
  1510. }
  1511.       }
  1512.       lit = blossomliste.succ(lit);
  1513.     }
  1514.   }
  1515.   if (!unterblossomliste.empty()) {
  1516.     list_item lit = unterblossomliste.first();
  1517.     while (lit != nil) {
  1518.       node_array <bool >schon_besucht(G, false);
  1519.       int anzknoten = 0;
  1520.       int anzgematchtekanten = 0;
  1521.       if ((unterblossomliste[lit].z > 0) &&
  1522. (!unterblossomliste[lit].knotenliste.empty())) {
  1523. list_item knotenlit = unterblossomliste[lit].knotenliste.first();
  1524. while (knotenlit != nil) {
  1525.   anzknoten++;
  1526.   node v = unterblossomliste[lit].knotenliste[knotenlit];
  1527.   if ((!schon_besucht[v]) && (gematchte_kante[v] != nil)) {
  1528.     schon_besucht[v] = true;
  1529.     edge e = gematchte_kante[v];
  1530.     node w = G.opposite(v, e);
  1531.     list_item knotenlit2 = unterblossomliste[lit].knotenliste.first();
  1532.     while (knotenlit2 != nil) {
  1533.       if (unterblossomliste[lit].knotenliste[knotenlit2] == w) {
  1534. break;
  1535.       }
  1536.       knotenlit2 = unterblossomliste[lit].knotenliste.succ(knotenlit2);
  1537.     }
  1538.     if (knotenlit2 != nil) {
  1539.       anzgematchtekanten++;
  1540.       schon_besucht[w] = true;
  1541.     }
  1542.   }
  1543.   knotenlit = unterblossomliste[lit].knotenliste.succ(knotenlit);
  1544. }
  1545. if (anzknoten != (2 * anzgematchtekanten + 1)) {
  1546.   cout << "Bedingung (4) ist verletzt!!!n";
  1547. }
  1548.       }
  1549.       lit = unterblossomliste.succ(lit);
  1550.     }
  1551.   }
  1552.   cout << "Test von Bedingung (4) abgeschlossen!n";
  1553.   return;
  1554. }
  1555. DUALER_TYP bestimme_z(const ugraph &G, const list <blossom > &blossomliste,
  1556.    const list <blossom > &unterblossomliste, const blossom & bl, const edge &e)
  1557. {
  1558.   DUALER_TYP z = bl.z;
  1559.   if (!bl.ub_zeiger_liste.empty()) {
  1560.     list_item ubzlit = bl.ub_zeiger_liste.first();
  1561.     while (ubzlit != nil) {
  1562.       int anzahl = 0;
  1563.       list_item ubllit = bl.ub_zeiger_liste[ubzlit];
  1564.       if (!unterblossomliste[ubllit].knotenliste.empty()) {
  1565. list_item knotenlit = unterblossomliste[ubllit].knotenliste.first();
  1566. while (knotenlit != nil) {
  1567.   node k = unterblossomliste[ubllit].knotenliste[knotenlit];
  1568.   if ((k == G.source(e)) || (k == G.target(e)))
  1569.     anzahl++;
  1570.   if (anzahl == 2)
  1571.     break;
  1572.   knotenlit = unterblossomliste[ubllit].knotenliste.succ(knotenlit);
  1573. }
  1574.       }
  1575.       if (anzahl == 2) {
  1576. z += bestimme_z(G, blossomliste, unterblossomliste,
  1577.   unterblossomliste[ubllit], e);
  1578. break;
  1579.       }
  1580.       else if (anzahl == 1)
  1581. break;
  1582.       ubzlit = bl.ub_zeiger_liste.succ(ubzlit);
  1583.     }
  1584.   }
  1585.   return z;
  1586. }