本文整理汇总了C++中Network::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::clear方法的具体用法?C++ Network::clear怎么用?C++ Network::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
#if 0
if( argc < 2) {
cout << "usage: " << argv[0] << " packagefile" << endl;
return 0;
}
DebianDependencyNetwork my_net(argv[1]);
cout << "#read debian package: " << argv[1] << endl;
/*
map<int, int> in_deg_dist = my_net.getOutDegreeDist();
map<int, int>::iterator deg_it = in_deg_dist.begin();
cout << "#printing out degree distribution" << endl;
while( deg_it != in_deg_dist.end() ) {
cout << deg_it->first << " " << deg_it->second << endl;
deg_it++;
}
//cout << "#cluster coeff: " << my_net.getClusterCoefficient() << endl;
*/
Network deb_undir;
cerr << "#about to move into an undirected network" << endl;
my_net.moveIntoUndirectedNetwork(deb_undir);
cerr << "#converted to undirected" << endl;
set<Node*>::iterator n = nodes.begin();
for(; n != nodes.end(); n++) {
cout << deb_undir.getDegree( *n ) << " "
<< deb_undir.getClusterCoefficient( *n ) << endl;
}
/*
map<int, int> deg_dist = deb_undir.getDegreeDist();
map<int, int>::iterator deg_it = deg_dist.begin();
cout << "#printing out degree distribution" << endl;
for(; deg_it != deg_dist.end(); deg_it++ ) {
cout << deg_it->first << " " << deg_it->second << endl;
}
cout << "#cluster coeff: " << deb_undir.getClusterCoefficient() << endl;
cout << "#edges: " << deb_undir.getEdges().size() << endl;
cout << "#nodes: " << deb_undir.getNodes().size() << endl;
*/
//Delete the allocated memory (nodes)
deb_undir.clear();
#endif
#if 0
set<Node*> all_nodes;
Network my_net;
//Make all the nodes:
for(int i = 0; i < 100; i++) {
all_nodes.insert( new Node() );
}
//Make a network:
set<Node*>::iterator n_it = all_nodes.begin();
Node* last_node = 0;
while(n_it != all_nodes.end()) {
if(last_node) {
my_net.add( Edge(last_node, *n_it) );
}
last_node = *n_it;
n_it++;
}
#endif
#if 0
/**
* Test transitivity calculation:
*/
Network* my_net;
Ran1Random my_rand;
double p = 0.1;
int n = 100;
while(p < 1.0) {
my_net = new RandomNetwork(n, p, my_rand);
cout << p << " " << my_net->getTransitivity() << endl;
p += 0.1;
}
#endif
#if 0
//Verify the assortativity calculation on a known case:
/**
* the callaway network should have assortativity p/(1+2p)
*/
DynamicNetwork* my_net = 0;
Ran1Random my_rand;
double p = 0.0;
cout << "#c <k> clustercoeff assort n" << endl;
while( p < 1.0 ) {
//my_net = new CallawayNetwork(10000, p, my_rand);
my_net = new PrefDelCompNetwork(RandomNetwork(20, 0.5, my_rand),
my_rand,
p,
1,
0.75); //Only restore connections with q=0.75
//.........这里部分代码省略.........