Main Page   Class Hierarchy   Compound List   File List   Compound Members  

relabeledEdge.h

00001 /****************************************************
00002  *  Bachelor Project:                               *
00003  *  External Memory Minimum Spanning Trees          *
00004  *  by Dominik Schultes <mail@dominik-schultes.de>  *
00005  *                                                  *
00006  *                relabeledEdge.h                   *
00007  *                                                  *
00008  *  April 22, 2003                                  *
00009  ****************************************************/
00010 
00011 #ifndef RELABELEDEDGE_H
00012 #define RELABELEDEDGE_H
00013 
00014 
00015 #include "edge.h"
00016 
00017 
00018 class RelabeledEdge;
00019     
00024 class RelabeledEdgeWithoutSource : public EdgeWithoutSource
00025 {
00030     friend std::ostream& operator<<( std::ostream& os,
00031                                      const RelabeledEdgeWithoutSource &e ) {
00032         os << e.target() << " " << e.weight() << " "
00033            << e.originalSource() << " " << e.originalTarget();
00034         return os;
00035     }
00036     
00037  public:
00039     RelabeledEdgeWithoutSource()
00040         : EdgeWithoutSource(), _originalSource( 0 ), _originalTarget( 0 )
00041         {}
00042     
00047     RelabeledEdgeWithoutSource( const RelabeledEdge &edge );
00048 
00050     NodeID originalSource() const {return _originalSource;}
00051 
00053     NodeID originalTarget() const {return _originalTarget;}
00054         
00055  private:
00056     NodeID _originalSource;
00057     NodeID _originalTarget;
00058 };
00059 
00060 
00067 class RelabeledEdge : public Edge
00068 {
00070     friend std::ostream& operator<<( std::ostream& os, const RelabeledEdge &e ) {
00071         os << e.source() << " " << e.target() << " " << e.weight() << " "
00072            << e.originalSource() << " " << e.originalTarget();
00073         return os;
00074     }
00075     
00076  public:
00078     static RelabeledEdge minWeight() {return RelabeledEdge(0,0,0,0,0);}
00079 
00081     static RelabeledEdge maxWeight() {return RelabeledEdge(0,0,0xffffffff,0,0);}
00082 
00083     
00085     RelabeledEdge(NodeID source = 0, NodeID target = 0, EdgeWeight weight = 0,
00086                   NodeID origSource = 0, NodeID origTarget = 0)
00087         : Edge( source,target,weight ),
00088           _originalSource( origSource ), _originalTarget( origTarget )
00089         {}
00090 
00095     RelabeledEdge(const Edge &edge)
00096         : Edge( edge ), _originalSource( edge.source() ),
00097                         _originalTarget( edge.target() )
00098         {}
00099 
00106     RelabeledEdge(const RelabeledEdgeWithoutSource &edge, NodeID newSource)
00107         : Edge( newSource, edge.target(), edge.weight() ),
00108           _originalSource( edge.originalSource() ), _originalTarget( edge.originalTarget() )
00109         {
00110             if (source() < target()) swap(); 
00111         }
00112     
00114     NodeID originalSource() const {return _originalSource;}
00115 
00117     NodeID originalTarget() const {return _originalTarget;}
00118 
00119     
00120  private:
00121     NodeID _originalSource;
00122     NodeID _originalTarget;
00123 };
00124 
00125 
00130 RelabeledEdgeWithoutSource::RelabeledEdgeWithoutSource( const RelabeledEdge &edge )
00131     : EdgeWithoutSource( edge.target(), edge.weight() ),
00132       _originalSource( edge.originalSource() ), _originalTarget( edge.originalTarget() )
00133 {}
00134 
00135 
00136 #endif // RELABELEDEDGE_H

Generated on Thu Aug 14 15:13:27 2003 for External Memory Minimum Spanning Trees by doxygen1.2.17