Grafalgo
Library of useful data structures and algorithms
|
00001 // Header file for class that implements Edmond's algorithm for 00002 // finding a maximum size matching in a general graph. To use, 00003 // invoke the constructor. 00004 00005 #ifndef EDMONDS_H 00006 #define EDMONDS_H 00007 00008 #include "stdinc.h" 00009 #include "Graph.h" 00010 #include "List.h" 00011 #include "Dlist.h" 00012 #include "RlistSet.h" 00013 #include "Partition.h" 00014 00015 using namespace grafalgo; 00016 00017 class edmonds { 00018 public: edmonds(Graph&,Dlist&,int&); 00019 string& statString(bool, string&); 00020 private: 00021 Graph* graf; // graph we're finding matching for 00022 Dlist* match; // matching we're building 00023 Partition *blossoms; // partition of the vertices into blossoms 00024 RlistSet* augpath; // reversible list used to construct path 00025 vertex* origin; // origin[u] is the original vertex 00026 // corresponding to a blossom 00027 struct BridgePair { // for an odd vertex u inside a blossom, 00028 edge e; vertex v; // bridge[u].e is the edge that caused the 00029 }; 00030 BridgePair *bridge; // formation of the innermost blossom containg u 00031 // bridge[u].v identifies the endpoint of the 00032 // edge that is u's descendant 00033 enum stype {unreached, odd, even}; 00034 stype *state; // state used in computation path search 00035 edge* mEdge; // mEdge[u] is matching edge incident to u 00036 edge* pEdge; // p[u] is parent of u in forest 00037 bool* mark; // used in nearest common ancestor computation 00038 00039 int iSize, mSize, stepCount, blossomCount; 00040 int imatchTime, rmatchTime, pathInitTime, pathFindTime; 00041 00042 vertex nca(vertex,vertex); // return nearest-common ancestor 00043 edge path(vertex,vertex); // construct augmenting path 00044 void augment(edge); // augment the matching 00045 edge findpath(); // find an altmenting path 00046 }; 00047 00048 #endif