WhiteheadGraph.h

Go to the documentation of this file.
00001 // Copyright (C) 2005 Alexander Ushakov
00002 // Contents: Definition of class WhiteheadGraph
00003 //
00004 // Principal Authors: Alexander Ushakov
00005 //
00006 // Revision History:
00007 //
00008 
00009 #ifndef _WhiteheadGraph_h_
00010 #define _WhiteheadGraph_h_
00011 
00012 
00013 #include "GraphType.h"
00014 #include "GraphConcept.h"
00015 #include "GraphConceptAlgorithms.h"
00016 using namespace Graphs;
00017 
00018 #include "Word.h"
00019 
00020 
00021 //---------------------------------------------------------------------------//
00022 //---------------------------- WhiteheadGraph -------------------------------//
00023 //---------------------------------------------------------------------------//
00024 
00025 
00026 class WhiteheadGraph
00027 {
00029   //                                                     //
00030   //  Constructors:                                      //
00031   //                                                     //
00033 
00034 public:
00035   WhiteheadGraph( int n_gens , const Word& w ) { assign( n_gens , w.begin( ) , w.end( ) ); }
00036 
00038   //                                                     //
00039   //  Accessors:                                         //
00040   //                                                     //
00042 
00043 public:
00044   template< class ConstIterator > void assign( int n_gens , ConstIterator B , ConstIterator E ) {
00045 
00046     if( B==E ) return;
00047     theGraph.clear( );
00048     for( int i=0 ; i<n_gens ; ++i ) {
00049       theGraph.newVertex( );
00050       theGraph.newVertex( );
00051     }
00052     
00053     int old_l = *--E;
00054     int old_num = old_l>0 ? 2*old_l-1 : -2*old_l-2;
00055     for( ++E ; B!=E ; ++B ) {
00056       int l = *B;
00057       int num = l>0 ? 2*l-1 : -2*l-2;
00058       theGraph.newEdge( old_num , num );
00059       // cout << old_num << ", " << num << endl;
00060       old_l = l;
00061       old_num = num;
00062     }
00063   }
00064   
00065   const Graph& getGraph( ) { return theGraph; }
00066         
00067 
00069   //                                                     //
00070   //  Data members:                                      //
00071   //                                                     //
00073 
00074 private:
00075 
00076   Graph theGraph;
00077 };
00078 
00079 
00080 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Mon Sep 26 18:43:45 2011 for CRyptography And Groups (CRAG) by  doxygen 1.6.1