本文整理汇总了C++中ListGraph::maxNodeId方法的典型用法代码示例。如果您正苦于以下问题:C++ ListGraph::maxNodeId方法的具体用法?C++ ListGraph::maxNodeId怎么用?C++ ListGraph::maxNodeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListGraph
的用法示例。
在下文中一共展示了ListGraph::maxNodeId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( void ){
Timer T(true);
int init_nodes_num, final_nodes_num, edge_addition_num;
init_nodes_num = 10;
final_nodes_num = 50;
edge_addition_num = 7;
typedef ListEdgeSet< ListGraph > EdgeSet;
ListGraph mListGraph;
EdgeSet mNewEdges( mListGraph );
FullGraph fg(init_nodes_num);
GraphCopy<FullGraph, ListGraph> cg( fg, mListGraph); // Create the seed nodes
cg.run();
int mNumEdges = countEdges( mListGraph );
EdgeSet::Edge e;
lemon::Random mRandom;
mRandom.seedFromTime();
ListGraph::Node newNode, randNode;
// new edges will be saved seperatly in an EdgeSet, not to change the original node degrees
for ( int i = init_nodes_num; i < final_nodes_num; i++){
mNumEdges = countEdges( mListGraph );
mNewEdges.clear();
newNode = mListGraph.addNode();
while ( countEdges( mNewEdges ) != edge_addition_num ) {
randNode = mListGraph.nodeFromId( mRandom[ mListGraph.maxNodeId() ] ) ;
// --- CALCULATE THE PROBABILITY
if ( mRandom.real() < (( (double)(countIncEdges(mListGraph, randNode)) / (double)( 2*mNumEdges ) )) ){
if ( findEdge( mNewEdges, newNode, randNode ) == INVALID){ // does the edge already exist?
mNewEdges.addEdge( newNode, randNode );
}
}
}
// Create the new edges in the original graph
for (EdgeSet::EdgeIt e( mNewEdges ); e!=INVALID; ++e){
mListGraph.addEdge( mNewEdges.u( e ), mNewEdges.v(e) );
}
}
cout << T.realTime() << endl;
cout << countEdges( mListGraph) << endl;
cout << countEdges( fg ) << endl;
}