[Lemon-user] Question regarding ListUGraph
Dragos Trinca
dnt04001 at engr.uconn.edu
Mon Jul 28 01:42:37 CEST 2008
Hi,
Yes, assigning information to nodes is exactly what I need. Thanks.
Now, I have one more question. I was looking for a function that removes nodes from a graph (and the corresponding edges), but I couldn't find one.
Does anyone know how to do that?
Thanks,
Dragos
________________________________
From: Balazs Dezso [mailto:deba at inf.elte.hu]
Sent: Mon 7/21/2008 4:34 AM
To: lemon-user at lemon.cs.elte.hu
Cc: Dragos Trinca
Subject: Re: [Lemon-user] Question regarding ListUGraph
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