本文整理汇总了C++中Graph::Delta方法的典型用法代码示例。如果您正苦于以下问题:C++ Graph::Delta方法的具体用法?C++ Graph::Delta怎么用?C++ Graph::Delta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph::Delta方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOCALARRAY
bool EdgeColoringTest<DefaultStructs>::test(const Graph &graph, const ColorMap &colors)
{
typedef typename Graph::PVertex Vert;
typedef typename Graph::PEdge Edge;
const EdgeDirection Mask = EdDirIn|EdDirOut|EdUndir;
int degree = graph.Delta(Mask);
int LOCALARRAY(kolory, degree+1);
int lenKolory = 0;
for(Vert vv = graph.getVert(); vv; vv = graph.getVertNext(vv)) {
lenKolory = 0;
for(Edge ee = graph.getEdge(vv, Mask); ee;
ee = graph.getEdgeNext(vv, ee, Mask))
{
if(!colors.hasKey(ee)) return false;
int col = colors[ee];
if(col<0) return false;
kolory[lenKolory++] = col;
}
DefaultStructs::sort(kolory, kolory+lenKolory);
int tmpLen = std::unique(kolory, kolory+lenKolory)-kolory;
if(tmpLen!=lenKolory)
return false;
}
return true;
}
示例2: delta
SeqEdgeColoringPar<DefaultStructs>::VizingState<Graph,ColorMap>::
VizingState(const Graph &g, ColorMap &c, int maxCol):
graph(g), delta(g.Delta(EdDirIn|EdDirOut|EdUndir)),
colors(c), notColored(maxCol), vertToTab( g.getVertNo() ),
edgeToList( g.getEdgeNo(EdDirIn|EdDirOut|EdUndir) )
{
typedef typename Graph::PVertex Vert;
typedef typename Graph::PEdge Edge;
const EdgeDirection Mask = EdDirIn|EdDirOut|EdUndir;
tabVert = new TabVert[ g.getVertNo() ];
colorToList = new int[ maxCol+1 ];
listEdgeCol = new ListEdgeCol[ g.getEdgeNo(Mask)+1 ];
maxColor = -1;
//init all lists
int ii = 0;
for(Vert vv = graph.getVert(); vv; vv = graph.getVertNext(vv)) {
vertToTab[vv] = ii;
tabVert[ii++].freeColor = 0;
}
for(int i=0; i<notColored; i++)
colorToList[i] = 0;
colorToList[notColored] = 1;
ii = 1; //we assume that colors are not set to any edge
for(Edge ee = graph.getEdge(Mask); ee;
ee = graph.getEdgeNext(ee, Mask), ii++)
{
edgeToList[ee] = ii;
listEdgeCol[ii].next = ii+1;
listEdgeCol[ii].prev = ii-1;
listEdgeCol[ii].edge = ee;
}
listEdgeCol[ii-1].next = 0;
if(ii==1) //if the graph is empty
colorToList[notColored] = 0;
if(colors.size()<=0) return;
for(Edge ee = graph.getEdge(Mask); ee;
ee = graph.getEdgeNext(ee, Mask))
{
if(!colors.hasKey(ee)) continue;
int tmpCol = colors[ee];
if(tmpCol<0 || tmpCol>=notColored)
continue;
changeColor(ee, notColored, tmpCol);
if(maxColor<tmpCol) maxColor = tmpCol;
}
}
示例3: makeSubgraph
int SeqEdgeColoringPar<DefaultStructs>::vizing(const Graph &graph,
ColorMap &colors, typename Graph::PEdge edge,
typename Graph::PVertex vert, int maxCol)
{
if(colors.hasKey(edge)&&colors[edge]>=0)
return -1;
typedef typename Graph::PVertex Vert;
typedef typename Graph::PEdge Edge;
const EdgeDirection Mask = EdDirIn|EdDirOut|EdUndir;
int degree = graph.Delta(Mask);
int mu = makeSubgraph(graph, std::make_pair(stdChoose(true), !edgeTypeChoose(Loop))).mu();
VizingState<Graph, ColorMap> vState(graph, colors, degree+mu);
vState.maxColor = maxCol;
//edge coloring
vizing(vState, edge, vert);
return colors[edge];
}