src/work/jacint/max_matching.h
changeset 1241 dadc9987c537
parent 921 818510fa3d99
equal deleted inserted replaced
4:c154a5f8fd93 5:55540210faa5
   151     void readNMapEdge(NMapE& map) {
   151     void readNMapEdge(NMapE& map) {
   152       NodeIt v;
   152       NodeIt v;
   153       for( G.first(v); G.valid(v); G.next(v)) {
   153       for( G.first(v); G.valid(v); G.next(v)) {
   154 	Edge e=map[v];
   154 	Edge e=map[v];
   155 	if ( G.valid(e) )
   155 	if ( G.valid(e) )
   156 	  G.tail(e) == v ? mate.set(v,G.head(e)) : mate.set(v,G.tail(e)); 
   156 	  G.source(e) == v ? mate.set(v,G.target(e)) : mate.set(v,G.source(e)); 
   157       } 
   157       } 
   158     } 
   158     } 
   159     
   159     
   160     ///Writes the matching stored to a \c Node map of \c Edges.
   160     ///Writes the matching stored to a \c Node map of \c Edges.
   161 
   161 
   170       for( G.first(v); G.valid(v); G.next(v)) {
   170       for( G.first(v); G.valid(v); G.next(v)) {
   171 	if ( mate[v]!=INVALID ) todo.set(v,true); 
   171 	if ( mate[v]!=INVALID ) todo.set(v,true); 
   172       }
   172       }
   173       NodeIt e;
   173       NodeIt e;
   174       for( G.first(e); G.valid(e); G.next(e)) {
   174       for( G.first(e); G.valid(e); G.next(e)) {
   175 	if ( todo[G.head(e)] && todo[G.tail(e)] ) {
   175 	if ( todo[G.target(e)] && todo[G.source(e)] ) {
   176 	  Node u=G.tail(e);
   176 	  Node u=G.source(e);
   177 	  Node v=G.head(e); 
   177 	  Node v=G.target(e); 
   178 	  if ( mate[u]=v && mate[v]=u ) {
   178 	  if ( mate[u]=v && mate[v]=u ) {
   179 	    map.set(u,e);
   179 	    map.set(u,e);
   180 	    map.set(v,e);
   180 	    map.set(v,e);
   181 	    todo.set(u,false);
   181 	    todo.set(u,false);
   182 	    todo.set(v,false);
   182 	    todo.set(v,false);
   194     template<typename EMapB>
   194     template<typename EMapB>
   195     void readEMapBool(EMapB& map) {
   195     void readEMapBool(EMapB& map) {
   196       EdgeIt e;
   196       EdgeIt e;
   197       for( G.first(e); G.valid(e); G.next(e)) {
   197       for( G.first(e); G.valid(e); G.next(e)) {
   198 	if ( G.valid(e) ) {
   198 	if ( G.valid(e) ) {
   199 	  Node u=G.tail(e);	  
   199 	  Node u=G.source(e);	  
   200 	  Node v=G.head(e);
   200 	  Node v=G.target(e);
   201 	  mate.set(u,v);
   201 	  mate.set(u,v);
   202 	  mate.set(v,u);
   202 	  mate.set(v,u);
   203 	} 
   203 	} 
   204       } 
   204       } 
   205     }
   205     }
   220       }
   220       }
   221       
   221       
   222       NodeIt e;
   222       NodeIt e;
   223       for( G.first(e); G.valid(e); G.next(e)) {
   223       for( G.first(e); G.valid(e); G.next(e)) {
   224 	map.set(e,false);
   224 	map.set(e,false);
   225 	if ( todo[G.head(e)] && todo[G.tail(e)] ) {
   225 	if ( todo[G.target(e)] && todo[G.source(e)] ) {
   226 	  Node u=G.tail(e);
   226 	  Node u=G.source(e);
   227 	  Node v=G.head(e); 
   227 	  Node v=G.target(e); 
   228 	  if ( mate[u]=v && mate[v]=u ) {
   228 	  if ( mate[u]=v && mate[v]=u ) {
   229 	    map.set(e,true);
   229 	    map.set(e,true);
   230 	    todo.set(u,false);
   230 	    todo.set(u,false);
   231 	    todo.set(v,false);
   231 	    todo.set(v,false);
   232 	  }
   232 	  }