本文整理汇总了C++中GraphAttributes::init方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphAttributes::init方法的具体用法?C++ GraphAttributes::init怎么用?C++ GraphAttributes::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphAttributes
的用法示例。
在下文中一共展示了GraphAttributes::init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getBasicGraphAttributes
//*************************************************************
// returns GraphAttributes associated with basic graph i
//
void SimDraw::getBasicGraphAttributes(int i, GraphAttributes &GA, Graph &G)
{
G = m_G;
GA.init(G,m_GA.attributes());
List<edge> LE;
m_G.allEdges(LE);
for(edge eLE : LE)
if(m_GA.inSubGraph(eLE,i))
{
for(node v : G.nodes)
{
if(compare(GA,v,m_GA,eLE->source()))
{
if(m_GA.attributes() & GraphAttributes::nodeGraphics)
{
GA.x(v) = m_GA.x(eLE->source());
GA.y(v) = m_GA.y(eLE->source());
GA.height(v) = m_GA.height(eLE->source());
GA.width(v) = m_GA.width(eLE->source());
}
if(m_GA.attributes() & GraphAttributes::nodeId)
GA.idNode(v) = m_GA.idNode(eLE->source());
if(m_GA.attributes() & GraphAttributes::nodeLabel)
GA.label(v) = m_GA.label(eLE->source());
}
if(compare(GA,v,m_GA,eLE->target()))
{
if(m_GA.attributes() & GraphAttributes::nodeGraphics)
{
GA.x(v) = m_GA.x(eLE->target());
GA.y(v) = m_GA.y(eLE->target());
GA.height(v) = m_GA.height(eLE->target());
GA.width(v) = m_GA.width(eLE->target());
}
if(m_GA.attributes() & GraphAttributes::nodeId)
GA.idNode(v) = m_GA.idNode(eLE->target());
if(m_GA.attributes() & GraphAttributes::nodeLabel)
GA.label(v) = m_GA.label(eLE->target());
}
}
for(edge e : G.edges)
{
if(compare(GA,e->source(),m_GA,eLE->source())
&& compare(GA,e->target(),m_GA,eLE->target()))
{
if(m_GA.attributes() & GraphAttributes::edgeIntWeight)
GA.intWeight(e) = m_GA.intWeight(eLE);
if(m_GA.attributes() & GraphAttributes::edgeLabel)
GA.label(e) = m_GA.label(eLE);
if(m_GA.attributes() & GraphAttributes::edgeStyle)
GA.strokeColor(e) = m_GA.strokeColor(eLE);
if(m_GA.attributes() & GraphAttributes::edgeGraphics)
GA.bends(e) = m_GA.bends(eLE);
}
}
}
else
{
List<edge> LE2;
G.allEdges(LE2);
for(edge e2 : LE2)
{
if(compare(GA,e2->source(),m_GA,eLE->source())
&& compare(GA,e2->target(),m_GA,eLE->target()))
{
G.delEdge(e2);
}
}
}
//remove all Nodes with degree == 0
//this can change the IDs of the nodes in G.
List<node> LN;
G.allNodes(LN);
for(node v : LN)
if(v->degree() == 0)
G.delNode(v);
}//end getBasicGraphAttributes
示例2: getBasicGraphAttributes
//*************************************************************
// returns GraphAttributes associated with basic graph i
//
void SimDraw::getBasicGraphAttributes(int i, GraphAttributes &GA, Graph &G)
{
G = m_G;
GA.init(G,m_GA.attributes());
List<edge> LE;
m_G.allEdges(LE);
forall_listiterators(edge,it,LE)
if(m_GA.inSubGraph(*it,i))
{
node v;
forall_nodes(v,G)
{
if(compare(GA,v,m_GA,(*it)->source()))
{
if(m_GA.attributes() & GraphAttributes::nodeGraphics)
{
GA.x(v) = m_GA.x((*it)->source());
GA.y(v) = m_GA.y((*it)->source());
GA.height(v) = m_GA.height((*it)->source());
GA.width(v) = m_GA.width((*it)->source());
}
if(m_GA.attributes() & GraphAttributes::nodeId)
GA.idNode(v) = m_GA.idNode((*it)->source());
if(m_GA.attributes() & GraphAttributes::nodeLabel)
GA.labelNode(v) = m_GA.labelNode((*it)->source());
}
if(compare(GA,v,m_GA,(*it)->target()))
{
if(m_GA.attributes() & GraphAttributes::nodeGraphics)
{
GA.x(v) = m_GA.x((*it)->target());
GA.y(v) = m_GA.y((*it)->target());
GA.height(v) = m_GA.height((*it)->target());
GA.width(v) = m_GA.width((*it)->target());
}
if(m_GA.attributes() & GraphAttributes::nodeId)
GA.idNode(v) = m_GA.idNode((*it)->target());
if(m_GA.attributes() & GraphAttributes::nodeLabel)
GA.labelNode(v) = m_GA.labelNode((*it)->target());
}
}
edge e;
forall_edges(e,G)
{
if(compare(GA,e->source(),m_GA,(*it)->source())
&& compare(GA,e->target(),m_GA,(*it)->target()))
{
if(m_GA.attributes() & GraphAttributes::edgeIntWeight)
GA.intWeight(e) = m_GA.intWeight(*it);
if(m_GA.attributes() & GraphAttributes::edgeLabel)
GA.labelEdge(e) = m_GA.labelEdge(*it);
if(m_GA.attributes() & GraphAttributes::edgeColor)
GA.colorEdge(e) = m_GA.colorEdge(*it);
if(m_GA.attributes() & GraphAttributes::edgeGraphics)
GA.bends(e) = m_GA.bends(*it);
}
}
}
示例3: consistencyCheck
// debug consistency check
bool BitonicOrdering::consistencyCheck(GraphAttributes& GA)
{
GA.init(m_graph, GraphAttributes::nodeLabel);
bool allBitonic = true;
for (node v = m_graph.firstNode(); v; v = v->succ())
{
std::stringstream str;
str << v<<"("<<m_orderIndex[v]<<")";
GA.label(v) = str.str();
if (m_orderIndex[v] < 0)
std::cout << "Node not assigned"<< std::endl;
}
// for all nodes we check now for bitonic indices
for (node v = m_graph.firstNode(); v; v = v->succ())
{
bool isNodeBitonic = true;
// we skip t and s though
if (m_orderIndex[v] == 0)
continue;
// we skip t and s though
if (m_orderIndex[v] == m_graph.numberOfNodes()-1)
continue;
adjEntry adj_first_succ = nullptr;
adjEntry adj_last_succ = nullptr;
for (adjEntry adj = v->firstAdj(); adj; adj = adj->succ())
{
// and its cyclic succ
node w_prev = adj->cyclicPred()->twinNode();
// the other node
node w = adj->twinNode();
// and its cyclic succ
node w_next = adj->cyclicSucc()->twinNode();
if ((m_orderIndex[v] > m_orderIndex[w_prev]) && (m_orderIndex[v] < m_orderIndex[w]))
adj_first_succ = adj;
if ((m_orderIndex[v] > m_orderIndex[w_next]) && (m_orderIndex[v] < m_orderIndex[w]))
adj_last_succ = adj;
}
// we are going to look for bitonic succ lists
for (adjEntry adj = v->firstAdj(); adj; adj = adj->succ())
{
// and its cyclic succ
node w_prev = adj->cyclicPred()->twinNode();
// the other node
node w = adj->twinNode();
// and its cyclic succ
node w_next = adj->cyclicSucc()->twinNode();
// not a succ
if (m_orderIndex[v] > m_orderIndex[w_prev])
continue;
// not a succ
if (m_orderIndex[v] > m_orderIndex[w])
continue;
// not a succ
if (m_orderIndex[v] > m_orderIndex[w_next])
continue;
// all succs, lets check for bitonic indices
if ((m_orderIndex[w_prev] >= m_orderIndex[w]) && (m_orderIndex[w_next] >= m_orderIndex[w]) && (m_orderIndex[v] > 0))
{
isNodeBitonic = false;
std::cout << "[BitonicOrder:] " << "NOT BITONIC SUCC LIST " << v<< "(" << m_orderIndex[v] << ")" << std::endl;
std::cout << "[BitonicOrder:] " << w_prev << "("<< m_orderIndex[w_prev] << ") " << w << "(" << m_orderIndex[w] << ") "<< w_next <<"("<<m_orderIndex[w_next] << ")"<<std::endl;
std::cout << std::endl;
};
}
if (!isNodeBitonic)
{
for (adjEntry adj = adj_first_succ; adj != adj_last_succ->cyclicSucc(); adj = adj->cyclicSucc())
{
std::cout << "("<< m_orderIndex[adj->twinNode()] << ") ";
}
}
allBitonic = allBitonic && isNodeBitonic;
}
return allBitonic;
}