本文整理汇总了C++中GraphT::source方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphT::source方法的具体用法?C++ GraphT::source怎么用?C++ GraphT::source使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphT
的用法示例。
在下文中一共展示了GraphT::source方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}