📄 analyzer_strongness.cpp
字号:
#include "analyzer_strongness.h"/** * Questo metodo serve per calcolare la strongness su differenti * backbone di differenti layer. */void analyze_strongness(string topologyDirectory, string resultFile, int selectedLayer, int trial, double * strongness_backbone, double * strongness_all, string & layerName, int & numNodes){ string topology, stack, currentLayer, s_tmp, color; vector<string> layers; NodeList backbone_nodes; int i, i_tmp; Graph graph, backbone; *strongness_backbone = 0; *strongness_all = 0; int count = 0; // Apre il file di risultato in lettura. istream * inFile; if (use_zipped) inFile = new igzstream((resultFile + ".gz").c_str()); else inFile = new ifstream((resultFile).c_str()); while (*inFile >> topology >> stack) { // cout << "( " << topology << " ) - [" << stack << "]"; cout << "."; cout.flush(); changeToGraph(topology); extractLayers(stack, layers); if (selectedLayer >= (int)layers.size()) { for (i = 0; i < (int)layers.size(); i++) { skipLayer(inFile); } } else { for (i = 0; i < selectedLayer; i++) { skipLayer(inFile); } // Analizza il layer giusto. *inFile >> currentLayer; // cout << ", Layer: " << currentLayer; layerName = layers[0]; for (int ll = 1; ll <= selectedLayer; ll++) layerName += "-" + layers[ll]; if ((currentLayer == "BACKBONE") || (currentLayer == "SHIVA") || (currentLayer == "CONNECTOR")) { // skip i dati in trasmissione dei nodi. *inFile >> i_tmp; numNodes = i_tmp; for (int t = 0; t < (i_tmp + 2); t++) getline(*inFile, s_tmp, '\n'); *inFile >> i_tmp; int t; backbone_nodes.clear(); for (t = 0; t < i_tmp; t++) { NodeList tmp_nodes; // Carica i colori dei nodi. readColor(inFile, color, tmp_nodes, false); if ((color == string("black")) || (color == string("gray"))) { for (NodeList::iterator n = tmp_nodes.begin(); n != tmp_nodes.end(); n++) backbone_nodes.insert(*n); } } // Carica il backbone del grafo. loadFromDump(inFile, graph); double strongness_backbone_tmp, strongness_all_tmp; // // Determina il backbone // loadFromFile((topologyDirectory + "/" + topology).c_str(), graph); graph_to_backbone(graph, backbone_nodes, backbone); average_strongness(backbone, backbone_nodes, trial, strongness_backbone_tmp, strongness_all_tmp); if ((strongness_backbone_tmp > 0) && (strongness_all_tmp > 0)) { *strongness_backbone += strongness_backbone_tmp; *strongness_all += strongness_all_tmp; count++; } } if ((currentLayer == "SHIVA") || (currentLayer == "CONNECTOR")) { getline(*inFile, s_tmp, '\n'); } // Salta tutti gli altri layer. for (++i; i < (int)layers.size(); i++) { skipLayer(inFile); } } } *strongness_backbone = (*strongness_backbone / count); *strongness_all = (*strongness_all / count); delete(inFile);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -