本文整理汇总了C++中ColorMap::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ColorMap::size方法的具体用法?C++ ColorMap::size怎么用?C++ ColorMap::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColorMap
的用法示例。
在下文中一共展示了ColorMap::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getColors
void Spectrum::getColors(ColorMap & m) const
{
m.assign( getDimCount(), AtomType() );
for( Dimension d = 0; d < m.size(); d++ )
m[ d ] = getColor( d );
}
示例2: LOCALARRAY
int SeqEdgeColoringPar<DefaultStructs>::vizingSimple(const Graph &graph,
ColorMap &colors)
{
typedef typename Graph::PVertex Vert;
typedef typename Graph::PEdge Edge;
const EdgeDirection Mask = EdDirIn|EdDirOut|EdUndir;
colors.reserve(graph.getEdgeNo(EdDirIn|EdDirOut|EdUndir));
int degree = graph.Delta(Mask);
VizingState<Graph, ColorMap> vState(graph, colors, degree+1);
int LOCALARRAY(tmpTab, vState.notColored);
//tmpTab - is used for checking free color availability
if(colors.size()>0) {
//for each vertex checks the free color availability (freeColor)
for(Vert vv = graph.getVert(); vv; vv = graph.getVertNext(vv)) {
for(int i=0; i<vState.notColored; i++)
tmpTab[i] = 0;
for(Edge ee=graph.getEdge(vv, Mask); ee;
ee = graph.getEdgeNext(vv, ee, Mask))
{
if(!colors.hasKey(ee)) continue;
int tmpCol = colors[ee];
if(tmpCol<0 || tmpCol>=vState.notColored) continue;
tmpTab[ tmpCol ] = 1;
}
int i=0;
while(i<vState.notColored && tmpTab[i]==1) i++;
vState.tabVert[ vState.vertToTab[vv] ].freeColor = i;
}
}
//init edges by degree colors
int ii;
for(Edge edge = graph.getEdge(Mask); edge;
edge = graph.getEdgeNext(edge, Mask))
{
if(colors.hasKey(edge)&&colors[edge]>=0) continue;
Vert vert1 = graph.getEdgeEnd1(edge);
Vert vert2 = graph.getEdgeEnd2(edge);
for(int i=0; i<degree; i++)
tmpTab[i] = 0;
for(Edge ee = graph.getEdge(vert1, Mask); ee;
ee = graph.getEdgeNext(vert1, ee, Mask))
{
if(!colors.hasKey(ee)) continue;
int tmpCol = colors[ee];
if(tmpCol<0 || tmpCol>=vState.notColored) continue;
tmpTab[ tmpCol ] = 1;
}
for(Edge ee=graph.getEdge(vert2, Mask); ee;
ee=graph.getEdgeNext(vert2, ee, Mask))
{
if(!colors.hasKey(ee)) continue;
int tmpCol = colors[ee];
if(tmpCol<0 || tmpCol>=vState.notColored) continue;
tmpTab[ tmpCol ] |= 2;
}
for(int i=0; i<degree; i++) {
if(tmpTab[i]!=0) continue;
colors[edge] = i;
vState.changeColor(edge, vState.notColored, i);
tmpTab[i] = 3; // 3=1|2
if(i > vState.maxColor)
vState.maxColor = i;
break;
}
//setting free colors at vertices
for(ii=0; ii<degree; ii++)
if((tmpTab[ii]&1)==0) break;
int id = vState.vertToTab[vert1];
vState.tabVert[id].freeColor = ii;
for(ii=0; ii<degree; ii++)
if((tmpTab[ii]&2)==0) break;
id = vState.vertToTab[vert2];
vState.tabVert[id].freeColor = ii;
}
//edge coloring
int idFree;
while( (idFree=vState.colorToList[vState.notColored])>0 ) {
Edge ee = vState.listEdgeCol[idFree].edge;
vizingSimple(vState, ee, ee->getEnd1());
}
return vState.maxColor;
}