本文整理汇总了C++中GraphT::target方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphT::target方法的具体用法?C++ GraphT::target怎么用?C++ GraphT::target使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphT
的用法示例。
在下文中一共展示了GraphT::target方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exportToGraphvizFormat_Nodal
bool exportToGraphvizFormat_Nodal(
const GraphT & g,
ostream & os)
{
os << "graph 1 {" << endl;
os << "node [shape=circle]" << endl;
//Export node label
for(typename GraphT::NodeIt n(g); n!= lemon::INVALID; ++n)
{
os << " n" << g.id(n) << std::endl;
}
//-- Export arc (as the graph is bi-directional, export arc only one time)
map< std::pair<size_t,size_t>, size_t > map_arcs;
for(typename GraphT::ArcIt e(g); e!=lemon::INVALID; ++e) {
if( map_arcs.end() == map_arcs.find(std::make_pair(size_t (g.id(g.source(e))), size_t (g.id(g.target(e)))))
&&
map_arcs.end() == map_arcs.find(std::make_pair(size_t (g.id(g.target(e))), size_t (g.id(g.source(e))))))
{
map_arcs[std::pair<size_t,size_t>(size_t (g.id(g.source(e))),
size_t (g.id(g.target(e)))) ] = 1;
}
}
//os << "edge [style=bold]" << endl;
for ( map< std::pair<size_t,size_t>, size_t >::const_iterator iter = map_arcs.begin();
iter != map_arcs.end();
++iter)
{
os << " n" << iter->first.first << " -- " << " n" << iter->first.second << endl;
}
os << "}" << endl;
return os.good();
}
示例2: exportToGraphvizFormat_Image
bool exportToGraphvizFormat_Image(
const GraphT & g,
const NodeMap & nodeMap,
const EdgeMap & edgeMap,
ostream & os, bool bWeightedEdge=false)
{
os << "graph 1 {" << endl;
os << "node [shape=none]" << endl;
//Export node label
for(typename GraphT::NodeIt n(g); n!=lemon::INVALID; ++n)
{
os << " n" << g.id(n)
<< "[ label ="
<<
"< "<< endl
<<"<table>"<< endl
<<"<tr><td>" << "\"" << nodeMap[n] <<"\"" <<"</td></tr>"<< endl
<<"<tr><td><img src=\"" << nodeMap[n] <<"\"/></td></tr>"<< endl
<<"</table>"<< endl
<<">, cluster=1];"<< endl;
//os << " n" << g.id(n)
// << " [ "
// << " image=\"" << nodeMap[n] << "\" cluster=1]; " << endl;
}
//Export arc value
map< std::pair<size_t,size_t>, size_t > map_arcs;
for(typename GraphT::ArcIt e(g); e!=lemon::INVALID; ++e) {
if( map_arcs.end() == map_arcs.find(std::make_pair(size_t (g.id(g.source(e))), size_t (g.id(g.target(e)))))
&&
map_arcs.end() == map_arcs.find(std::make_pair(size_t (g.id(g.target(e))), size_t (g.id(g.source(e))))))
{
map_arcs[std::pair<size_t,size_t>(size_t (g.id(g.source(e))),
size_t (g.id(g.target(e)))) ] = edgeMap[e];
}
}
os << "edge [style=bold]" << endl;
for ( map< std::pair<size_t,size_t>, size_t >::const_iterator iter = map_arcs.begin();
iter != map_arcs.end();
++iter)
{
if (bWeightedEdge)
{
os << " n" << iter->first.first << " -- " << " n" << iter->first.second
<< " [label=\"" << iter->second << "\"]" << endl;
}
else
{
os << " n" << iter->first.first << " -- " << " n" << iter->first.second << endl;
}
}
os << "}" << endl;
return os.good();
}
示例3: List_Triplets
bool List_Triplets(const GraphT & g, std::vector< Triplet > & vec_triplets)
{
// Algorithm
//
//-- For each node
// - list the outgoing not visited edge
// - for each tuple of edge
// - if their end are connected
// Detected cyle of length 3
// Mark first edge as visited
typedef typename GraphT::OutArcIt OutArcIt;
typedef typename GraphT::NodeIt NodeIterator;
typedef typename GraphT::template EdgeMap<bool> BoolEdgeMap;
BoolEdgeMap map_edge(g, false); // Visited edge map
// For each nodes
for (NodeIterator itNode(g); itNode != INVALID; ++itNode)
{
// For each edges (list the not visited outgoing edges)
std::vector<OutArcIt> vec_edges;
for (OutArcIt e(g, itNode); e!=INVALID; ++e)
{
if (!map_edge[e]) // If not visited
vec_edges.push_back(e);
}
// For all tuples look of ends of edges are linked
while(vec_edges.size()>1)
{
OutArcIt itPrev = vec_edges[0]; // For all tuple (0,Inth)
for(size_t i=1; i < vec_edges.size(); ++i)
{
// Check if the extremity is linked
typename GraphT::Arc cycleEdge = findArc(g, g.target(itPrev), g.target(vec_edges[i]));
if (cycleEdge!= INVALID && !map_edge[cycleEdge])
{
// Elementary cycle found (make value follow a monotonic ascending serie)
int triplet[3] = {
g.id(itNode),
g.id(g.target(itPrev)),
g.id(g.target(vec_edges[i]))};
std::sort(&triplet[0], &triplet[3]);
vec_triplets.push_back(Triplet(triplet[0],triplet[1],triplet[2]));
}
}
// Mark the current ref edge as visited
map_edge[itPrev] = true;
// remove head to list remaining tuples
vec_edges.erase(vec_edges.begin());
}
}
return (!vec_triplets.empty());
}