我正在尝试从 omnet++ 中提取网络图,并将节点信息和链接提供给柠檬图。问题的一部分很容易处理。使用代码:
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++;
不知何故,我得到了节点列表,现在我也在尝试获取链接信息。也就是说,节点和它们之间的链接也是如此。如何获取链接信息并将其提供给 Lemon 图,我在代码中使用的方法有什么问题?