本文整理汇总了C++中Network::TotNodeWeights方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::TotNodeWeights方法的具体用法?C++ Network::TotNodeWeights怎么用?C++ Network::TotNodeWeights使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::TotNodeWeights方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]) {
if( argc < 10){
cout << "Call: ./ompRelaxmap <seed> <network.net> <# threads> <# attempts> <threshold> <vThresh> <maxIter> <outDir> <prior/normal> [selflinks]" << endl;
exit(-1);
}
string outDir = string(argv[8]);
int maxIter = atoi(argv[7]); // Set the maximum number of iteration..
int Ntrials = atoi(argv[4]); // Set number of partition attempts
int numThreads = atoi(argv[3]); // Set number of threads...
string line;
string buf;
MTRand *R = new MTRand(stou(argv[1]));
string infile = string(argv[2]);
string networkFile = string(argv[2]);
string networkName(networkFile.begin() + networkFile.find_last_of("/"), networkFile.begin() + networkFile.find_last_of("."));
string networkType(infile.begin() + infile.find_last_of("."), infile.end());
double threshold = atof(argv[5]);
double vThresh = atof(argv[6]); // vertex-threshold: threshold for each vertex-movement.
cout << "Threshold = " << threshold << ", Vertex-Threshold = " << vThresh << endl;
vThresh *= -1; // change the threshold value for negative.
string priorFlag = string(argv[9]);
bool prior = false;
if (priorFlag == "prior")
prior = true;
bool includeSelfLinks = false;
if(argc == 11) {
string selfLinks(argv[10]);
if(selfLinks == "selflinks")
includeSelfLinks = true;
}
Network origNetwork; // default constructor is called.
origNetwork.R = R;
// time values for measuring elapsed times for each step...
struct timeval allStart, allEnd;
struct timeval noIOstart, noIOend;
struct timeval start, end;
gettimeofday(&allStart, NULL);
gettimeofday(&start, NULL);
if(networkType == ".net"){
load_pajek_format_network(networkFile, origNetwork);
}
else{
load_linkList_format_network(networkFile, origNetwork);
}
gettimeofday(&end, NULL);
cout << "Time for reading input data : " << elapsedTimeInSec(start, end) << " (sec)" << endl;
gettimeofday(&noIOstart, NULL);
int nNode = origNetwork.NNode();
double totNodeWeights = origNetwork.TotNodeWeights();
cout << "total Node weights = " << totNodeWeights << endl;
gettimeofday(&start, NULL);
for (int i = 0; i < nNode; i++) {
origNetwork.nodes[i].setTeleportWeight(origNetwork.nodes[i].NodeWeight()/totNodeWeights);
}
int NselfLinks = 0;
for(map<pair<int,int>,double>::iterator it = origNetwork.Edges.begin(); it != origNetwork.Edges.end(); it++){
int from = it->first.first;
int to = it->first.second;
double weight = it->second;
if(weight > 0.0){
if(from == to){
NselfLinks++;
//if(includeSelfLinks)
// origNetwork.nodes[from]->selfLink += weight;
}
else{
origNetwork.nodes[from].outLinks.push_back(make_pair(to,weight));
// we will going to update inLinks, after we got final flow of the network.
//origNetwork.nodes[to].inLinks.push_back(make_pair(from,weight));
}
}
}
if(includeSelfLinks)
//cout << "including " << NselfLinks << " self link(s)." << endl;
cout << "current version always excludes self links.\nignoring " << NselfLinks << " self link(s)." << endl;
//.........这里部分代码省略.........