bool NetworkProfiler::creatSimpleModuleGraph(yarp::profiler::graph::Graph& graph, yarp::profiler::graph::Graph& subgraph) { subgraph.clear(); pvertex_const_iterator itr; const pvertex_set& vertices = graph.vertices(); //insert machines for(itr = vertices.begin(); itr!=vertices.end(); itr++) { if(!dynamic_cast<MachineVertex*>(*itr)) continue; else { auto* mv1 = dynamic_cast<MachineVertex*>(*itr); if (mv1) { MachineVertex* mv2 = new MachineVertex(mv1->property.find("os").asString(), mv1->property.find("hostname").asString()); mv2->property = mv1->property; subgraph.insert(*mv2); } } } for(itr = vertices.begin(); itr!=vertices.end(); itr++) { if(!dynamic_cast<ProcessVertex*>(*itr)) continue; auto* pv1 = dynamic_cast<ProcessVertex*>(*itr); if (pv1) { ProcessVertex* pv2 = new ProcessVertex(pv1->property.find("pid").asInt32(), pv1->property.find("hostname").asString()); pv2->property = pv1->property; subgraph.insert(*pv2); } } // insert edges for(itr = vertices.begin(); itr!=vertices.end(); itr++) { if(!dynamic_cast<ProcessVertex*>(*itr)) continue; Vertex* v1 = (*itr); const edge_set& outs = v1->outEdges(); edge_const_iterator eitr; for(eitr = outs.begin(); eitr!=outs.end(); eitr++) { const Edge& e = (*eitr); const Vertex& p1 = e.second(); const edge_set& pouts = p1.outEdges(); edge_const_iterator peitr; for(peitr = pouts.begin(); peitr!=pouts.end(); peitr++) { const Vertex& p2 = (*peitr).second(); Property prop((*peitr).property); string lable = p1.property.find("name").asString(); lable.append(" - ").append(p2.property.find("name").asString()); prop.put("lable", lable); subgraph.insertEdge(*v1, p2.outEdges()[0].second(), prop); } } } return true; }