本文整理汇总了C++中Network::NModule方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::NModule方法的具体用法?C++ Network::NModule怎么用?C++ Network::NModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::NModule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_twoLevel_Cluster
void print_twoLevel_Cluster(Network network, string networkName, string outDir) {
ofstream outFile;
ostringstream oss;
oss << outDir << "/" << networkName << ".tree";
outFile.open(oss.str().c_str());
outFile << "# Code length " << network.CodeLength()/log(2.0) << " in " << network.NModule() << " modules." << endl;
int nModules = network.modules.size();
int modIdx = 0;
for (int i = 0; i < nModules; i++) {
int nMembers = network.modules[i].NumMembers();
if (nMembers > 0)
modIdx++;
for (int j = 0; j < nMembers; j++) {
outFile << modIdx << ":" << j+1 << " " << network.modules[i].members[j]->Size() << " \"" << network.modules[i].members[j]->Name() << "\"" << endl;
}
}
outFile.close();
}
示例2: main
//.........这里部分代码省略.........
}
}
if(includeSelfLinks)
//cout << "including " << NselfLinks << " self link(s)." << endl;
cout << "current version always excludes self links.\nignoring " << NselfLinks << " self link(s)." << endl;
else
cout << "ignoring " << NselfLinks << " self link(s)." << endl;
//Swap vector to free memory
map<pair<int,int>,double>().swap(origNetwork.Edges);
cout << "DONE: Parsing the given network ..." << endl;
gettimeofday(&end, NULL);
cout << "Time for parsing the given network : " << elapsedTimeInSec(start, end) << " (sec)" << endl;
gettimeofday(&start, NULL);
// Initialization.
origNetwork.initiate(numThreads);
// Now update inLinks..
for (int i = 0; i < nNode; i++) {
int nOutLinks = origNetwork.nodes[i].outLinks.size();
for (int j = 0; j < nOutLinks; j++)
origNetwork.nodes[origNetwork.nodes[i].outLinks[j].first].inLinks.push_back(make_pair(i,origNetwork.nodes[i].outLinks[j].second));
}
gettimeofday(&end, NULL);
cout << "DONE: Initiate() ... in " << elapsedTimeInSec(start, end) << " (sec)" << endl;
cout << "Initial Code Length: " << origNetwork.CodeLength()/log(2.0) << " in " << origNetwork.NModule() << " modules.\n";
// copy size of each node for print in order.
vector<double> nodeSize(nNode);
for (int i = 0; i < nNode; i++)
nodeSize[i] = origNetwork.nodes[i].Size();
cout << "Now partition the network starts...\n";
gettimeofday(&start, NULL);
bool fineTune = true;
bool fast = false; // This will be true only for sub-module partitioning...
int step = 1;
// Initial SuperStep running ...
double oldCodeLength = origNetwork.CodeLength();
stochastic_greedy_partition(origNetwork, numThreads, threshold, vThresh, maxIter, prior, fineTune, fast);
cout << "SuperStep [" << step << "] - codeLength = " << origNetwork.CodeLength()/log(2.0) << " in " << origNetwork.NModule() << " modules." << endl;
bool nextIter = true;
if ((oldCodeLength - origNetwork.CodeLength())/log(2.0) < threshold)
nextIter = false;
struct timeval subStart, subEnd;
while (nextIter) {