Main Page   Class Hierarchy   Compound List   File List   Compound Members  

PG_ostream.hpp

00001 #ifndef _PG_OSTREAM_HPP_
00002 #define _PG_OSTREAM_HPP_
00003 
00004 #include "boost/tuple/tuple.hpp"
00005 #include <ostream>
00006 #include <iomanip>
00007 
00008 namespace ParGraph
00009 {
00010 
00011 template< class P >
00012 std::ostream& operator<< ( std::ostream &os, const OwnerComputesGraph<P> &g )
00013 {
00014   for( proc_t p = 0 ; p < size() ; p++ )
00015   {
00016     MPI_Barrier( _libbase.comm() );
00017     if( p == rank() )
00018     {
00019       typename OwnerComputesGraph<P>::const_VertexIterator vit, vend;
00020       boost::tie( vit, vend ) = g.get_local_vertices();
00021       for(; vit != vend ; vit++ )
00022       {
00023         os << "P" << _libbase.rank() << ":  ID " << std::setw(2) << std::right << get_id(*vit) << ": ";
00024         os << g.get_property_reference( *vit ) << std::endl;
00025       }
00026     }
00027   }
00028   MPI_Barrier( _libbase.comm() );
00029   return os;
00030 }
00031 
00032 template< class TAG, class TYPE, class NEXT >
00033 std::ostream& operator<< ( std::ostream &os, const property<TAG,TYPE,NEXT> &prop )
00034 {
00035   return os << std::boolalpha << get_property_value( prop, TAG() ) << ", " << (NEXT) prop;
00036 }
00037 
00038 template< class TAG, class TYPE >
00039 std::ostream& operator<< ( std::ostream &os, const property<TAG,TYPE,no_property> &prop )
00040 {
00041   return os << std::boolalpha << get_property_value( prop, TAG() );
00042 }
00043 
00044 std::ostream& operator<< ( std::ostream &os, default_color_type c )
00045 {
00046   switch( c )
00047   {
00048     case black_color: return os << "black";
00049     case gray_color:  return os << "gray";
00050     case white_color: return os << "white";
00051   }
00052   return os;
00053 }
00054 
00055 template< class P >
00056 std::ostream& operator<< ( std::ostream &os, const EdgeList<P,directed_out_edges_type> &edges )
00057 {
00058   typename EdgeList<P,directed_out_edges_type>::const_mapiterator ebegin, eit, eend;
00059   boost::tie( ebegin, eend ) = out_edges( edges );
00060   std::cout << "-> { ";
00061   for( eit = ebegin ; eit != eend ; eit++ )
00062   {
00063     if( eit != ebegin ) std::cout << ", ";
00064     std::cout << eit->first << ";" << get_id(eit->second->get_v2()) << "( " << eit->second.get_property_reference() << ")";
00065   }
00066   return os << " }";
00067 }
00068 
00069 template< class P >
00070 std::ostream& operator<< ( std::ostream &os, const EdgeList<P,directed_in_out_edges_type> &edges )
00071 {
00072   typename EdgeList<P,directed_in_out_edges_type>::const_mapiterator ebegin, eit, eend;
00073   boost::tie( ebegin, eend ) = out_edges( edges );
00074   std::cout << "-> { ";
00075   for( eit = ebegin ; eit != eend ; eit++ )
00076   {
00077     if( eit != ebegin ) std::cout << ", ";
00078     std::cout << eit->first << ";" << get_id(eit->second.get_v2()) << "( " << eit->second.get_property_reference() << ")";
00079   }
00080   typename EdgeList<P,directed_in_out_edges_type>::const_mapiterator ebegin2, eit2, eend2;
00081   boost::tie( ebegin2, eend2 ) = in_edges( edges );
00082   std::cout << " } <- { ";
00083   for( eit2 = ebegin2 ; eit2 != eend2 ; eit2++ )
00084   {
00085     if( eit2 != ebegin2 ) std::cout << ", ";
00086     std::cout << eit2->first << ";" << get_id(eit2->second.get_v2()) << "( " << eit2->second.get_property_reference() << ")";
00087   }
00088   return os << " }";
00089 }
00090 
00091 std::ostream& operator<< ( std::ostream &os, const no_property& )
00092 {
00093   return os;
00094 }
00095 
00096 }
00097 #endif // _PG_OSTREAM_HPP_

Generated on Sun Feb 29 05:14:24 2004 for ParGraph by doxygen1.3-rc3