'LEMON Graph library: Inheritance in Maps
in my PhD project, I want to create a graph using LEMON. The graph itself is directed and hierarchical meaning that the graph has a tree-like shape. The leaves arcs point to higher nodes in the hierarchy and end up in a final node at the top. I want to use LEMON since I think that it provides a simpler mechanism than other libraries. Some implementations for instance are: getting pointers for nodes that are linked to a certain node in the graph.
In addition, I want to create a custom map that maps nodes to my custom objects which inherit all from one parent class. Is it possible to create a custom map that has something like this struct:
struct MyMap
{
typedef std::shared_ptr<ParentClass> value;
typedef Digraph::Node Key;
std::shared_ptr<ParentClass> operator[](const Key &e) const { return value;}
};
In my code than I init the map within the graph like:
ListDigraph g;
ListDigraph::Node x = g.addNode();
ListDigraph::Node y = g.addNode();
g.addArc(x,y);
ListDigraph::NodeMap<MyMap> map(g);
std::shared_ptr<ParentClass> childA = std::make_shared<ChildClassA>();
std::shared_ptr<ParentClass> childB = std::make_shared<ChildClassB>();
map[x] = childA;
map[y] = childB;
(I hope I got everything correct here without code linting :) )
Would this be possible with LEMON?
Other questions which concern me:
- What is the easiest approach to get the nodes which point (directed arc and the node is the target) to a certain node?
- Is there a way to serialize the built graph or to save it as a .yaml, .json, .xml, etc?
Kind regards, KT
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|