I am trying to extract a graph of network from omnet++ and feed the information of nodes and links to the Lemon graph. The part of the problem is easy to deal with. Using the code:
cTopology *topo = new cTopology("topo");
std::vector<std::string> nedTypes;
nedTypes.push_back("inet.node.inet.StandardHost");
topo->extractByNedTypeName(nedTypes);
int numNodes = topo->getNumNodes();
EV << "cTopology found " << topo->getNumNodes() << " nodes\n";
ListDigraph g;
ListDigraph::NodeMap<std::string> nodeName(g);
for (ListDigraph::NodeIt n(g); n != INVALID; ++n)
{
int i = 0;//counter
int numOutLinks = topo->getNode(i)->getNumOutLinks();
g.addNode();
std::vector<std::string> nodeList;
nodeName[n] = topo->getNode(i)->getModule()->getName();
nodeList.push_back(nodeName[n]);
for(int j = 0; j<numOutLinks; j++)
{
cTopology::LinkOut* lOut = topo->getNode(i)->getLinkOut(j);
cTopology::Node *rNode = lOut->getRemoteNode();
for (auto& nlist : nodeList)
{
auto nodeFound = std::find(std::begin(nlist), std::end(nlist), rNode);
if(nodeFound != std::end(nlist)){
g.addNode();
g.addArc(g.nodeFromId(i), g.nodeFromId(i+1));
}
}
} i++;
Somehow I am getting the list of nodes and now I am trying to get the link information as well. That is, nodes and the links between them as well. How do I get the links information and feed it to Lemon graph and what is wrong in the approach I used in the code?