#include <TMBoostLA.h>
Public Member Functions | |
TMBoostLA () | |
virtual | ~TMBoostLA () |
virtual void | handleUpdate (TMPacket *pkt) |
virtual void | write2gml (string fname) |
virtual void | handleLinkStateUpdate (LSMPacket *pkt) |
virtual void | handleMetaDataUpdate (MetaDataPacket *pkt) |
virtual void | calcFIDsFromTM_2_Nodes () |
Protected Member Functions | |
virtual void | initialize (int stage) |
virtual int | numInitStages () const |
virtual void | finish () |
virtual void | initializeGraph () |
virtual Vertex | getVertex (string nodeid) |
virtual bool | vertexExists (string nodeid) |
virtual Edge | getEdge (string lid, bool &found) |
virtual bool | setEdgeWeights (string IIID) |
virtual string | getFIDFromBoostResult_rec (Vertex src, Vertex dst, vector< Vertex > pre) |
virtual vector< string > | getPathFromBoostResult_rec (Vertex src, Vertex dst, vector< Vertex > pre) |
virtual string | getFIDFromPath (vector< string > path) |
virtual double | getWeightFromBoostResult_rec (Vertex src, Vertex dst, vector< Vertex > pre) |
Protected Attributes | |
GraphWrapper< VertexProp, EdgeProp > | g |
The graph representation. | |
weightMap | weightmap |
I don't think it is used in this version. | |
Private Types | |
typedef GraphWrapper < VertexProp, EdgeProp > ::Vertex | Vertex |
typedef GraphWrapper < VertexProp, EdgeProp >::Edge | Edge |
typedef GraphWrapper < VertexProp, EdgeProp > ::EdgePair | EdgePair |
typedef GraphWrapper < VertexProp, EdgeProp > ::Graph | Graph |
typedef property_map< Graph, edge_weight_t >::type | weightMap |
typedef std::vector< Vertex > | predecessormap |
typedef std::vector< double > | distancemap |
Extended Boost Topology Manager Application. Performs a traditional shortest path calculation and assigned each Subscriber to the closest Publisher.
typedef std::vector<double> TMBoostLA::distancemap [private] |
typedef GraphWrapper<VertexProp,EdgeProp>::Edge TMBoostLA::Edge [private] |
typedef GraphWrapper<VertexProp,EdgeProp>::EdgePair TMBoostLA::EdgePair [private] |
typedef GraphWrapper<VertexProp,EdgeProp>::Graph TMBoostLA::Graph [private] |
typedef std::vector<Vertex> TMBoostLA::predecessormap [private] |
typedef GraphWrapper<VertexProp,EdgeProp>::Vertex TMBoostLA::Vertex [private] |
typedef property_map<Graph, edge_weight_t>::type TMBoostLA::weightMap [private] |
TMBoostLA::~TMBoostLA | ( | ) | [virtual] |
void TMBoostLA::calcFIDsFromTM_2_Nodes | ( | ) | [virtual] |
Calculates the FID from the Topology Manager to every node of the network according to the shortest path.
00421 { 00422 // predecessor_map 00423 std::vector<Vertex> p(g.getVertexCount()); 00424 // distance_map 00425 std::vector<double> d(g.getVertexCount()); 00426 00427 Vertex src = getVertex(myNodeId); 00428 00429 //XXX::The Topology manager is not path of the network in the simulation! Be carefull!!! 00430 dijkstra_shortest_paths(g.getGraph(), src, predecessor_map(&p[0]).distance_map(&d[0])); 00431 // For all nodes - update! 00432 for (TMtoNodes::iterator it = tm2nodes.begin(); it!=tm2nodes.end(); ++it){ 00433 00434 Vertex dst = getVertex(it->first); 00435 it->second = lidOR(getFIDFromBoostResult_rec(src, dst, p), getNodeInternalLID(it->first)); 00436 } 00437 // WoW Easier than it sounds! 00438 }
void TMBoostLA::finish | ( | ) | [protected, virtual] |
The finish function of the Boost Topology Manager.
Reimplemented from TMInterface.
00039 { 00040 TMInterface::finish(); 00041 00042 //Clear Graph 00043 g.clear(); 00044 }
TMBoostLA::Edge TMBoostLA::getEdge | ( | string | lid, | |
bool & | found | |||
) | [protected, virtual] |
Get an edge based on the LID...
00110 { 00111 GraphWrapper<VertexProp,EdgeProp>::edge_iterator ei, eend; 00112 for (tie(ei, eend) = g.getEdges(); ei != eend; ++ei) { 00113 if (g.properties(*ei).lid.compare(lid)==0) { 00114 found=true; 00115 return *ei; 00116 } 00117 } 00118 found=false; 00119 // ? 00120 return Edge(); 00121 }
string TMBoostLA::getFIDFromBoostResult_rec | ( | Vertex | src, | |
Vertex | dst, | |||
vector< Vertex > | pre | |||
) | [protected, virtual] |
Visit the predecessor map and calculate FID for a single destination/sub. RECURSIVE
00141 { 00142 00143 Vertex pre_v = pre[dst]; 00144 00145 // Terminal Condition! Add node it 00146 if (dst == src) return ""; 00147 00148 // Get the edge for pre_v - dst. NOT THE OPPOSITE! 00149 std::pair<Edge, bool> edge_res= g.getEdge(pre_v,dst); 00150 if (edge_res.second == false){ 00151 opp_error("*** NO EDGE FOR pre_v - dst: Check topology initializer, THIS SHOULD NEVER HAPPEN"); 00152 return ""; 00153 } 00154 00155 Edge e = edge_res.first; 00156 00157 // Get all the previous recursively 00158 string newfid=getFIDFromBoostResult_rec(src,pre_v,pre); 00159 00160 newfid=lidOR(newfid,g.properties(e).lid); 00161 00162 return newfid; 00163 }
string TMBoostLA::getFIDFromPath | ( | vector< string > | path | ) | [protected, virtual] |
00166 { 00167 //The variable to OR the various lids 00168 string newfid=""; 00169 00170 //For all elements of the path, calculate the FID 00171 for(uint i=0;i<path.size();i++) { 00172 newfid=lidOR(newfid,path[i]); 00173 } 00174 00175 return newfid; 00176 }
vector< string > TMBoostLA::getPathFromBoostResult_rec | ( | Vertex | src, | |
Vertex | dst, | |||
vector< Vertex > | pre | |||
) | [protected, virtual] |
Visit the predecessor map and find out all the path lids. RECURSIVE
00179 { 00180 //Find the next hop 00181 Vertex pre_v = pre[dst]; 00182 //The variable to preserve the path lid so far found 00183 vector<string> path; 00184 00185 // Terminal Condition! Add node it 00186 if (dst == src) return path; 00187 00188 // Get the edge for pre_v - dst. NOT THE OPPOSITE! 00189 std::pair<Edge, bool> edge_res= g.getEdge(pre_v,dst); 00190 if (edge_res.second == false){ 00191 opp_error("*** NO EDGE FOR pre_v - dst: Check topology initializer, THIS SHOULD NEVER HAPPEN"); 00192 return path; 00193 } 00194 00195 Edge e = edge_res.first; 00196 00197 // Get all the previous recursively 00198 path=getPathFromBoostResult_rec(src,pre_v,pre); 00199 00200 path.push_back(g.properties(e).lid); 00201 00202 return path; 00203 }
TMBoostLA::Vertex TMBoostLA::getVertex | ( | string | nodeid | ) | [protected, virtual] |
Get a vertex by nodeid, it returns UINT_MAX in case that the vertex is not found!
00098 { 00099 00100 GraphWrapper<VertexProp,EdgeProp>::vertex_iterator vi, vend; 00101 for (tie(vi, vend) = g.getVertices(); vi != vend; ++vi) { 00102 if (g.properties(*vi).nodeid.compare(nodeid)==0) return *vi; 00103 } 00104 00105 return UINT_MAX; 00106 00107 }
double TMBoostLA::getWeightFromBoostResult_rec | ( | Vertex | src, | |
Vertex | dst, | |||
vector< Vertex > | pre | |||
) | [protected, virtual] |
Visit the predecessor map and calculate path weight for a single destination/sub. RECURSIVE
00218 { 00219 00220 Vertex pre_v = pre[dst]; 00221 00222 // Terminal Condition! Add node it 00223 if (dst == src) return(0); 00224 00225 // Get the edge for pre_v - dst. NOT THE OPPOSITE! 00226 std::pair<Edge, bool> edge_res= g.getEdge(pre_v,dst); 00227 if (edge_res.second == false){ 00228 opp_error("*** NO EDGE FOR pre_v - dst: Check topology initializer, THIS SHOULD NEVER HAPPEN"); 00229 return(0); 00230 } 00231 00232 Edge e = edge_res.first; 00233 00234 // Get all the previous recursively 00235 double weight=getWeightFromBoostResult_rec(src,pre_v,pre); 00236 00237 weight+=g.properties(e).weight; 00238 00239 return weight; 00240 }
void TMBoostLA::handleLinkStateUpdate | ( | LSMPacket * | pkt | ) | [virtual] |
Handles the packets carrying link state status information. -- DUMMY
Implements TMInterface.
00441 { 00442 ev << " - TMBoostLA::handleLinkStateUpdate" << endl; 00443 00444 int replen = pkt->getRepLen(); 00445 bool found=false; 00446 for (int i=0; i<replen; i++){ 00447 Edge e = getEdge(pkt->getLid(i),found); 00448 if (!found){ 00449 cerr<<"TMBoostLA: LID NOT FOUND!: "<<pkt->getLid(i)<<endl; 00450 continue; 00451 } 00452 g.properties(e).status = pkt->getLinkStatus(i); 00453 } 00454 00455 //write2gml("/tmp/top.graphml"); 00456 }
void TMBoostLA::handleMetaDataUpdate | ( | MetaDataPacket * | pkt | ) | [virtual] |
Handles the MetaData packets received directly from the publishers.
Implements TMInterface.
00519 { 00520 updateInformationItemMetaData(pkt); 00521 }
void TMBoostLA::handleUpdate | ( | TMPacket * | pkt | ) | [virtual] |
Handle packet function for Click Modular Router. Called by the handleMessage() function of the Omnet++ module.
Implements TMInterface.
00247 { 00248 00249 ev << " - TMBoostLA::handleUpdate" << endl; 00250 00251 //Update the Information Items in the Topology Manager and return the Information Item ID in a hex form 00252 string hex_id = updateInformationItems(tmpkt); 00253 00254 //Re-initialize weights 00255 //Setting the weights map 00256 weightmap = get(edge_weight, g.getGraph()); 00257 00258 //Set the weight-map weight for the Dijkstra operation 00259 if(!setEdgeWeights(hex_id)) 00260 return; 00261 00262 // Search all the IItems and run algorithm for the changed 00263 for (InfoItems::iterator it = ii.begin(); it!=ii.end(); ++it){ 00264 00265 ev << " - Checking: " << it->first << " status: " << it->second.ii_updated << endl; 00266 // Not changed... continue 00267 if (!it->second.ii_updated) continue; 00268 00269 IIDetails *itd = &it->second; 00270 // Check that we have publishers 00271 if (itd->pubs.size() == 0){ 00272 ev << " - SHIT: No Publishers for item " << it->first << "???" << endl; 00273 ev << " - What should i do??? " << endl; 00274 itd->ii_updated = false; 00275 //itd->fid_updated = false; 00276 continue; 00277 } 00278 00279 // Check that we have subscribers 00280 if (itd->subs.size() == 0){ 00281 ev << " - No Subscribers for item " << it->first << endl; 00282 // Cancel the transmission 00283 itd->ii_updated = false; 00284 //itd->fid_updated = true; 00285 // Clear fids for all publishers of the Information Item 00286 for(uint i=0;i<itd->pubs.size();i++) { 00287 itd->pubs[i].fid = ""; 00288 itd->pubs[i].fid_updated = true; 00289 } 00290 continue; 00291 } 00292 00293 // Clear fids and paths for all publishers of the Information Item 00294 for(uint i=0;i<itd->pubs.size();i++) { 00295 //Clear fids 00296 itd->pubs[i].fid = ""; 00297 //Clear the link paths 00298 itd->pubs[i].paths.empty(); 00299 //Update the fid_update flag for the selected publisher 00300 itd->pubs[i].fid_updated = true; 00301 } 00302 00303 /* 00304 * The weight vector collects the link weight of every path from every publisher to 00305 * every subscriber. Therefore for it has the following format: 00306 * 00307 * Number of Subs 00308 * |-----------------------------------------| 00309 * N |P1-S1|P1-S2|P1-S3|P1-S4| ... | ... | ... | 00310 * u |-----+-----+-----+-----+-----+-----+-----| 00311 * m |P2-S1|P2-S2| ... | ... | ... | ... | ... | 00312 * b |-----+-----+-----+-----+-----+-----+-----| 00313 * e |P3-S1|P3-S2| ... | ... | ... | ... | ... | 00314 * r |-----+-----+-----+-----+-----+-----+-----| 00315 * |P4-S1| ... | ... | ... | ... | ... | ... | 00316 * o |-----+-----+-----+-----+-----+-----+-----| 00317 * f | ... | ... | ... | ... | ... | ... | ... | 00318 * |-----+-----+-----+-----+-----+-----+-----| 00319 * P | ... | ... | ... | ... | ... | ... | ... | 00320 * u |-----+-----+-----+-----+-----+-----+-----| 00321 * b | ... | ... | ... | ... | ... | ... | ... | 00322 * s |-----+-----+-----+-----+-----+-----+-----| 00323 * | ... | ... | ... | ... | ... | ... | ... | 00324 * |-----------------------------------------| 00325 * 00326 * For the path weight calculation, each line is divided and the minimum cell is 00327 * chosen. This cell will reveal the publisher selected for this subscriber. 00328 */ 00329 00330 //Vector for counting the weight of the path for each publisher source 00331 std::vector< vector<double> > weight_vector( itd->subs.size(), vector<double>(itd->pubs.size(),0.0) ); 00332 00333 00334 // Vector of predecessor_maps 00335 std::vector<predecessormap> pre_maps(itd->pubs.size()); 00336 00337 // Vector of distance_maps 00338 std::vector<distancemap> dis_maps(itd->pubs.size()); 00339 00340 // ------------------------------------------------------------------------------ // 00341 // -------- Find path from every publisher and check who is the best one -------- // 00342 // ------------------------------------------------------------------------------ // 00343 for(uint pindex=0;pindex<itd->pubs.size();pindex++) { 00344 00345 // Here we take the 1st publisher! Optimization could be done! 00346 Vertex tempsrc = getVertex(itd->pubs[pindex].pub); 00347 00348 // Sanity Check 00349 if (tempsrc == UINT_MAX){ 00350 opp_error("*** What THE HELL: Check your topology parser, NO VERTEX FOR PUBLISHER ??? "); 00351 continue; 00352 } 00353 00354 // Yay... Do the job... 00355 // predecessor_map 00356 std::vector<Vertex> p(g.getVertexCount()); 00357 // distance_map 00358 std::vector<double> d(g.getVertexCount()); 00359 00360 ev << " - Going for item " << it->first << " published from vertex " << tempsrc << endl; 00361 00362 dijkstra_shortest_paths(g.getGraph(), tempsrc, predecessor_map(&p[0]).distance_map(&d[0])); 00363 00364 //Save results of predecessor and distance maps 00365 pre_maps[pindex]=p; 00366 dis_maps[pindex]=d; 00367 00368 for (uint i=0; i<itd->subs.size(); ++i){ 00369 Vertex dst = getVertex(itd->subs[i]); 00370 weight_vector[i][pindex]=getWeightFromBoostResult_rec(tempsrc, dst, p); 00371 } 00372 } 00373 // ------------------------------------------------------------------------------ // 00374 00375 // ------------------------------------------------------------------------------ // 00376 // -- For each subscriber find the best publisher and add the fid of the route -- // 00377 // ------------------------------------------------------------------------------ // 00378 for(uint sindex=0; sindex<itd->subs.size(); sindex++) { 00379 //Access the 1D vector of weights (for this subscriber) 00380 std::vector<double> sub_weight=weight_vector[sindex]; 00381 00382 //Find the position of the publisher with the minimum weight spanning tree 00383 int minPos=std::min_element(sub_weight.begin(),sub_weight.end())-sub_weight.begin(); 00384 00385 ev << "Source selected: " << itd->pubs[minPos].pub << " for subscriber " << itd->subs[sindex] << endl; 00386 00387 //Select as src the found publisher 00388 Vertex src = getVertex(itd->pubs[minPos].pub); 00389 00390 // predecessor_map 00391 std::vector<Vertex> p(g.getVertexCount()); 00392 p=pre_maps[minPos]; 00393 // distance_map 00394 std::vector<double> d(g.getVertexCount()); 00395 d=dis_maps[minPos]; 00396 00397 // Make the fid and path for the selected subscriber 00398 Vertex dst = getVertex(itd->subs[sindex]); 00399 //Get the path lids from the specified source to the specified destination 00400 vector<string> boostPath=getPathFromBoostResult_rec(src, dst, p); 00401 itd->pubs[minPos].paths.insert(itd->pubs[minPos].paths.end(),boostPath.begin(),boostPath.end()); 00402 // Get FID src to dst 00403 itd->pubs[minPos].fid = lidOR(itd->pubs[minPos].fid, getFIDFromPath(itd->pubs[minPos].paths)); 00404 // Add the dst node internal LID! is needed 00405 itd->pubs[minPos].fid = lidOR(itd->pubs[minPos].fid, getNodeInternalLID(itd->subs[sindex])); 00406 00407 ev << " - FID Found " << src << ": " << itd->pubs[minPos].fid << endl; 00408 } 00409 // ------------------------------------------------------------------------------ // 00410 // Update Flags 00411 //itd->fid_updated = true; // NEWFID 00412 itd->ii_updated = false; // UNMODIFIED SINCE LAST RUN 00413 } 00414 00415 // Here we should be done! Update all the publishers with new FIDs 00416 updateAllThePublishers(); 00417 00418 }
void TMBoostLA::initialize | ( | int | stage | ) | [protected, virtual] |
Initialization function
Reimplemented from TMInterface.
00047 { 00048 00049 TMInterface::initialize(stage); 00050 00051 //The TMInterace Initialized at stage 2. To be safe 00052 //let's initialize on stage later. 00053 if(stage==3) { 00054 // At this stage the Topology Manager configuration is fed to Boost++ 00055 initializeGraph(); 00056 //write2gml("InitialGraph.gml"); 00057 } 00058 }
void TMBoostLA::initializeGraph | ( | ) | [protected, virtual] |
Initialize BGraph from topology
00064 { 00065 00066 for (uint i=0; i<topology.size(); ++i){ 00067 // Check n Add source 00068 Vertex src = getVertex(topology[i].src); 00069 if (src == UINT_MAX){ 00070 VertexProp vp; 00071 vp.nodeid=topology[i].src; 00072 src=g.addVertex(vp); 00073 } 00074 00075 // Check n Add destination 00076 Vertex dst = getVertex(topology[i].dst); 00077 if (dst == UINT_MAX){ 00078 VertexProp vp; 00079 vp.nodeid=topology[i].dst; 00080 dst=g.addVertex(vp); 00081 } 00082 00083 // NOTE: Avoid LOOPs !! 00084 if (dst==src) continue; 00085 00086 // Add edge 00087 EdgeProp ep; 00088 ep.weight = 1; // FIXME:TODO Initial weight! 00089 ep.lid = topology[i].lid; 00090 g.addEdge(src,dst,ep); 00091 } 00092 00093 //Setting the weights map 00094 weightmap = get(edge_weight, g.getGraph()); 00095 }
virtual int TMBoostLA::numInitStages | ( | ) | const [inline, protected, virtual] |
bool TMBoostLA::setEdgeWeights | ( | string | IIID | ) | [protected, virtual] |
Set the weight for the specified edge, according to the report sent by the network modules.
00459 { 00460 00461 //Find the Information Item, in the list of all the known ones 00462 InfoItems::iterator it=ii.find(IIID); 00463 00464 if(it==ii.end()) { 00465 ev << "Unknown Information Item requested in TM, " << endl; 00466 return(false); 00467 } 00468 00469 //For all edges, compute their weights according to the QoS requirements of the Information Item 00470 GraphWrapper<VertexProp,EdgeProp>::edge_iterator ei, eend; 00471 for (tie(ei, eend) = g.getEdges(); ei != eend; ++ei) { 00472 QoSList param=g.properties(*ei).status; 00473 00474 //Make sure we have all the necessary QoS parameters for the weight computation 00475 if(param.find(QoS_USEDRATE)!=param.end() && param.find(QoS_CAPACITY_M)!=param.end() && param.find(QoS_COST)!=param.end() && 00476 it->second.metadata.find(QoS_BW_M)!=it->second.metadata.end() && it->second.metadata.find(QoS_FLOW)!=it->second.metadata.end()) { 00477 00478 //If the link is empty 00479 if(param.find(QoS_USEDRATE)->second==0) { 00480 g.properties(*ei).weight = 1; 00481 weightmap[*ei]=g.properties(*ei).weight; 00482 } 00483 //If there are any links that have space for the new stream calculate with a weight given by the selected formula 00484 else if( (param.find(QoS_CAPACITY_M)->second - param.find(QoS_USEDRATE)->second) > it->second.metadata.find(QoS_BW_M)->second) { 00485 g.properties(*ei).weight = (double)pow((double)(param.find(QoS_CAPACITY_M)->second - param.find(QoS_USEDRATE)->second)/param.find(QoS_CAPACITY_M)->second,3); 00486 weightmap[*ei]=g.properties(*ei).weight; 00487 } 00488 //If the link is full... 00489 else { 00490 //Check if the Information Item is currently passing through the examined link 00491 bool pass=false; 00492 for(uint i=0;i<it->second.pubs.size();i++) { 00493 if(find(it->second.pubs[i].paths.begin(),it->second.pubs[i].paths.end(),g.properties(*ei).lid) != it->second.pubs[i].paths.end()) 00494 pass=true; 00495 } 00496 00497 //If it is passing calculate with a weight given by the selected formula 00498 if(pass) { 00499 g.properties(*ei).weight = (double)pow((double)(param.find(QoS_CAPACITY_M)->second - param.find(QoS_USEDRATE)->second)/param.find(QoS_CAPACITY_M)->second,3); 00500 weightmap[*ei]=g.properties(*ei).weight; 00501 } 00502 //Other wise give it a big weight 00503 else { 00504 g.properties(*ei).weight = 10; 00505 weightmap[*ei]=g.properties(*ei).weight; 00506 } 00507 } 00508 } 00509 //Else set the standard weight equal to 2 - the maximum 00510 else { 00511 g.properties(*ei).weight = 10; 00512 weightmap[*ei]=g.properties(*ei).weight; 00513 } 00514 } 00515 return(true); 00516 }
bool TMBoostLA::vertexExists | ( | string | nodeid | ) | [protected, virtual] |
Check that a vertex exists by nodeid
00124 { 00125 return (!getVertex(nodeid) == UINT_MAX); 00126 }
void TMBoostLA::write2gml | ( | string | fname | ) | [virtual] |
Extracts the network graph in a xml format, proving the ability of monitoring the network on runtime.
00524 { 00525 // Chinese Language with mixed Greek follows! 00526 std::ofstream fout(fname.c_str()); 00527 if (!fout) return; 00528 00529 string top="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> \n\ 00530 <graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:y=\"http://www.yworks.com/xml/graphml\" xmlns:yed=\"http://www.yworks.com/xml/yed/3\" xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd\"> \n\ 00531 <key id=\"key0\" for=\"node\" attr.name=\"id\" attr.type=\"string\" />\n\ 00532 <key id=\"key1\" for=\"edge\" attr.name=\"weight\" attr.type=\"int\" /> \n\ 00533 <key id=\"key2\" for=\"edge\" attr.name=\"lid\" attr.type=\"string\" />\n\ 00534 <key for=\"edge\" id=\"d12\" yfiles.type=\"edgegraphics\"/> \n\ 00535 <key for=\"node\" id=\"d7\" yfiles.type=\"nodegraphics\"/>\n\ 00536 <graph id=\"G\" edgedefault=\"directed\" parse.nodeids=\"canonical\" parse.edgeids=\"canonical\" parse.order=\"nodesfirst\">\n"; 00537 00538 fout.write(top.c_str(), top.length()); 00539 00540 GraphWrapper<VertexProp,EdgeProp>::vertex_iterator vi, vend; 00541 for (tie(vi, vend) = g.getVertices(); vi != vend; ++vi) { 00542 VertexProp p = g.properties(*vi); 00543 string nodestr="<node id=\""+p.nodeid+"\">\n"; 00544 nodestr+=" <data key=\"key0\">"+p.nodeid+"</data>\n"; 00545 nodestr+=" <data key=\"d7\">\n\ 00546 <y:GenericNode configuration=\"ShinyPlateNode\">\n\ 00547 <y:NodeLabel alignment=\"center\" autoSizePolicy=\"content\" fontFamily=\"Dialog\" fontSize=\"12\" fontStyle=\"plain\" hasBackgroundColor=\"false\" hasLineColor=\"false\" height=\"4.0\" modelName=\"internal\" modelPosition=\"s\" textColor=\"#000000\" visible=\"true\" width=\"4.0\" >"+p.nodeid+"</y:NodeLabel>\n\ 00548 </y:GenericNode>\n\ 00549 </data>\n"; 00550 nodestr+="</node>\n"; 00551 00552 fout.write(nodestr.c_str(), nodestr.length()); 00553 } 00554 00555 int count=0; 00556 GraphWrapper<VertexProp,EdgeProp>::edge_iterator ei, eend; 00557 for (tie(ei, eend) = g.getEdges(); ei != eend; ++ei) { 00558 EdgeProp p = g.properties(*ei); 00559 stringstream ss; 00560 ss<<"e"<<count; 00561 count++; 00562 string lid=chararray_to_bin(p.lid); 00563 00564 string edgestr = "<edge id=\""+ss.str()+"\" source=\""+g.getSourceProp(*ei).nodeid+ 00565 "\" target=\""+g.getTargetProp(*ei).nodeid+"\">\n"; 00566 ss.clear(); 00567 ss.str(std::string()); 00568 ss<<p.weight; 00569 edgestr += " <data key=\"key1\">"+ss.str()+"</data>\n"; 00570 edgestr += " <data key=\"key2\">"+lid+"</data>\n"; 00571 edgestr+=" <data key=\"d12\">\n\ 00572 <y:PolyLineEdge>\n\ 00573 <y:Arrows source=\"none\" target=\"delta\"/>\n\ 00574 </y:PolyLineEdge>\n\ 00575 </data>\n"; 00576 edgestr += "</edge>\n"; 00577 fout.write(edgestr.c_str(), edgestr.length()); 00578 } 00579 00580 string bottom=" </graph>\n</graphml>"; 00581 fout.write(bottom.c_str(), bottom.length()); 00582 fout.close(); 00583 }
GraphWrapper<VertexProp, EdgeProp> TMBoostLA::g [protected] |
The graph representation.
weightMap TMBoostLA::weightmap [protected] |
I don't think it is used in this version.