analyzer_degree.cpp

来自「clustering for ns-2 simulation」· C++ 代码 · 共 45 行

CPP
45
字号
#include "analyzer_degree.h"void analyze_degree(string topologyDirectory,					int nodi,					map<int, int> & degree_id, 					map<int, int> & degree_degree,					map<int, int> & degree_altro){	Graph graph;		degree_id.clear();	degree_degree.clear();		int tmp1, tmp2, i;	for (i = 0; i < 300; i++) {		string tmpFile;		ostringstream fileName(tmpFile, ios::out);		fileName << topologyDirectory << "/" << nodi << "/graphS" << i << "N" << nodi;				// Carica il file di topologia dalla directory di topologia.		loadFromFile(fileName.str().c_str(), graph);						for (Graph::iterator n = graph.begin(); n != graph.end(); n++) {			tmp1 = 0;			tmp2 = 0;						// Conta tutti i vicini maggiori di un nodo a seconda del			// criterio di maggioranza.			for (NodeList::iterator nn = n->second.begin(); nn != n->second.end(); nn++) {				if ((*nn) > (n->first))					tmp1++;				if ((graph[*nn].size() > n->second.size()) ||					((graph[*nn].size() == n->second.size()) &&					 ((*nn) > n->first)))					tmp2++;			}			degree_id[tmp1]++;			degree_degree[tmp2]++;			degree_altro[tmp2 - tmp1]++;		}	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?