本文整理汇总了C++中ColorMap::delKey方法的典型用法代码示例。如果您正苦于以下问题:C++ ColorMap::delKey方法的具体用法?C++ ColorMap::delKey怎么用?C++ ColorMap::delKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColorMap
的用法示例。
在下文中一共展示了ColorMap::delKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOCALARRAY
int SeqEdgeColoringPar<DefaultStructs>::colorInterchange(const Graph &graph, ColorMap &colors,
typename Graph::PEdge edge)
{
typedef typename Graph::PVertex Vert;
typedef typename Graph::PEdge Edge;
const EdgeDirection Mask = EdDirIn|EdDirOut|EdUndir;
int oldColor = colors[ edge ]; //oldColor is maximal color in the graph
colors.delKey( edge );
Vert vert1 = graph.getEdgeEnd1(edge);
Vert vert2 = graph.getEdgeEnd2(edge);
int deg = graph.deg(vert1, Mask) + graph.deg(vert2, Mask);
char LOCALARRAY(matchedColors, deg);
for(int i=0; i<deg; i++) matchedColors[i] = 0;
for(Edge ee = graph.getEdge(vert1, Mask); ee;
ee = graph.getEdgeNext(vert1, ee, Mask))
{
if(!colors.hasKey(ee)) continue;
int col = colors[ee];
if(col<0 || col>=deg) continue;
matchedColors[col] |= 1;
}
for(Edge ee = graph.getEdge(vert2, Mask); ee;
ee = graph.getEdgeNext(vert2, ee, Mask))
{
if(!colors.hasKey(ee)) continue;
int col = colors[ee];
if(col<0 || col>=deg) continue;
matchedColors[col] |= 2;
}
VizingState<Graph, ColorMap> vState(graph, colors, oldColor);
int idVert1 = vState.vertToTab[vert1];
int idVert2 = vState.vertToTab[vert2];
for(int c1 = 0; c1<oldColor; c1++) {
for(int c2 = c1+1; c2<oldColor; c2++)
{
if((matchedColors[c1]&1)!=0 && (matchedColors[c2]&1)!=0)
continue;
if((matchedColors[c1]&2)!=0 && (matchedColors[c2]&2)!=0)
continue;
int begPath, endPath, colPath;
if((matchedColors[c1]&1)!=0) {
begPath = idVert1;
endPath = idVert2;
colPath = c1;
} else if((matchedColors[c2]&1)!=0) {
begPath = idVert1;
endPath = idVert2;
colPath = c2;
} else if((matchedColors[c1]&2)!=0) {
begPath = idVert2;
endPath = idVert1;
colPath = c1;
} else if((matchedColors[c2]&2)!=0) {
begPath = idVert2;
endPath = idVert1;
colPath = c2;
}
vState.subgraph(c1, c2);
if(vState.altPathWalk(begPath, colPath)==endPath)
continue;
vState.altPathRecoloring(begPath, colPath);
colors[edge] = colPath;
return colPath;
}
}
return colors[edge] = oldColor; //recoloring failed
}