[Lemon-user] Question regarding ListUGraph
Balazs Dezso
deba at inf.elte.hu
Mon Jul 21 10:34:42 CEST 2008
Hi
In the implemented graphs (List, Smart) you cannot change the node or edge
type, but perhaps you would like to assign some data to each node. In such
case you can use the NodeMap, and EdgeMap types:
ListUGraph g;
ListUGraph::Node n = g.addNode();
ListUGraph::NodeMap<int> im(g);
im[n] = 12;
std::cerr << im[n] << std::endl;
What is perhaps enough for you:
ListUGraph g;
ListUGraph::NodeMap<T> tm(g);
Generally, it is quite enough to store data for each node or edge in a graph.
In special cases, when your graph can be build on-the-fly, or some sparser
representation could be made for the graph, then own graph type could be
implemented, which node type could be whatever you want. For this purpose
there are some helper classes, but it is a harder topic...
Best, Balazs
On Sunday 20 July 2008 22:14:36 Dragos Trinca wrote:
> Hi,
>
> I need to use the class ListUGraph in such a way that every node in the
> graph is of my defined type, say ``T'' (where T can be anything), and not
> of type ``Node'' (as implicitly is).
>
> Does anyone know how to add nodes of locally defined type ``T'' to a graph
> ?
>
> Thanks in advance,
>
> Dragos
More information about the Lemon-user
mailing list