[Lemon-user] Node/Arc Validity

Kovács Péter kpeter at inf.elte.hu
Tue Oct 4 10:56:01 CEST 2011


Hi Vladimir,

> Even if I create a wrapper, when I use the NodeMaps, I have to
 > get rid of it.

Yes.

> Is there a way to set the minimal node ID of a graph?

No. And it wouldn't be a good choice, as most graph structures store the 
node and arc data in vectors in which the indices are the same as the 
IDs of the nodes/arcs. So if you set the minimum ID, it would worsen the 
performance of the graph structures.

 > Then I can say that all nodes with id greater than X are from G2 and
 > the rest come from G1.

 > I thought of solving the problem by using a map container with
 > <ListDigraph::Node*, bool> but I came to the conclusion that the
 > lemon maps may not store a reference to the original Node object and,
 > thus, mapping the pointer is of completely no use. Is this the case?

As we wrote before, Node and Arc objects are simple wrappers for a 
single int index (in most cases). Thus, such objects are not stored, 
they are created every time you require them. Do not use Node* pointers, 
use Node objects directly instead.

Regards,
Peter


>
> Regards,
>
> Vladimir
>
> -----Original Message-----
> From: Kovács Péter [mailto:kpeter at inf.elte.hu]
> Sent: Thursday, September 29, 2011 10:04 PM
> To: Todorov, Vladimir
> Cc: lemon-user at lemon.cs.elte.hu
> Subject: Re: [Lemon-user] Node/Arc Validity
>
> Hi Vladimir,
>
> For efficiency reasons, node and arc objects do not contain references
> to the graph. Actually, Node and Arc classes are simply wrapper classes
> containing a single int value (index). The valid() function checks for a
> node if its index is valid in the graph. If you create e.g. two
> ListDigraph and add a node to each graph, the two Node objects will be
> equal. You cannot differentiate between them, so there is no such
> function you are looking for in LEMON.
>
> If you really need this feature, you could e.g. define a wrapper class
> containing a Node and a reference to the graph object that contains the
> node.
>
> Regards,
> Peter
>
>
> On 2011.09.29. 13:19, Todorov, Vladimir wrote:
>> Hi,
>>
>> I have a problem using lemon. I use the method valid() to check whether
>> a node/arc belongs to a graph. The problem is that when I have two
>> graphs G1 and G2 and check if a node N from G1 is valid in G2 it returns
>> true… This must not be the case. If there is another method for checking
>> the affiliation of a node I would be happy to know it.
>>
>> Regards,
>>
>> Vladimir
>>
>




More information about the Lemon-user mailing list