42 #ifndef EpetraExt_TCRSGRAPH_MAPCOLORINGINDEX_H
43 #define EpetraExt_TCRSGRAPH_MAPCOLORINGINDEX_H
46 #include <Epetra_GIDTypeVector.h>
47 #include <Epetra_MapColoring.h>
62 template<
typename int_type>
64 :
public StructuralTransform< Epetra_CrsGraph,std::vector<typename Epetra_GIDTypeVector<int_type>::impl> > {
80 : ColorMap_( ColorMap )
94 template<
typename int_type>
99 if(!orig.RowMap().
template GlobalIndicesIsType<int_type>())
100 throw "EpetraExt::TCrsGraph_MapColoringIndex::operator(): Global indices mismatch.";
102 Base::origObj_ = &orig;
107 int NumColors = ColorMap_.NumColors();
108 int * ListOfColors = ColorMap_.ListOfColors();
110 std::map<int,int> MapOfColors;
111 for(
int i = 0; i < NumColors; ++i ) MapOfColors[ ListOfColors[i] ] = i;
114 std::vector<int_type> dummy( nRows, -1 );
117 int MaxNumIndices = orig.MaxNumIndices();
119 std::vector<int_type> Indices( MaxNumIndices );
121 for(
int i = 0; i < nRows; ++i )
123 orig.ExtractGlobalRowCopy( (int_type) orig.GRID64(i), MaxNumIndices, NumIndices, &Indices[0] );
125 for(
int j = 0; j < NumIndices; ++j )
126 (*IndexVec)[ MapOfColors[ColorMap_(Indices[j])] ][i] = Indices[j];
129 Base::newObj_ = IndexVec;
136 #endif // EpetraExt_TCRSGRAPH_MAPCOLORINGINDEX_H