[Lemon-user] FW: O(1) method to get number of arcs and nodes

Kovács Péter kpeter at inf.elte.hu
Thu May 7 23:22:44 CEST 2009


Hi,

as Balazs said the recommended way for obtaining the number of nodes, 
arcs, and incomming/outgoing arcs of a node etc. is using the 
corresponding global functions:

   int countNodes (const Graph &g)
   int countArcs (const Graph &g)
   int countEdges (const Graph &g)
   int countOutArcs (const Graph &g, const typename Graph::Node &n)
   int countInArcs (const Graph &g, const typename Graph::Node &n)
   int countIncEdges (const Graph &g, const typename Graph::Node &n)

You can find them in the module "Basic Graph Utilities" of the 
documentation. That's why nodeNum() and arcNum() are missing from the 
doc of SmartDigraph.

For SmartDigraph and SmartGraph these global functions are just 
equivalent to the member functions and they run in O(1) time,
but the global functions can be used for _all_ graph structures 
(including graph adaptors, arc/edge sets, as well) even if they don't 
have corresponding member functions. However note that in such cases the 
global functions run in linear time.

Best regards,
Peter


Balazs Dezso írta:
> Hi,
> 
> the best is to use the global functions countNodes() and countArcs(), because 
> these functions are specialized for SmartDigraph and they call directly the 
> SmartDigraph::nodeNum() and SmartDigraph::arcNum() functions. 
> 
> Best, Balazs
> 
> On Thursday 07 May 2009 22:35:44 Goldberg, Noam wrote:
>> Sorry.  I did find arcNum()
>> and nodeNum() in the source code.
>> it just seems to be missing from the documentation of SmartDigraph and/or
>> SmartDigraphBase
>>
>> Noam
>> ________________________________________
>> From: lemon-user-bounces at lemon.cs.elte.hu
>> [lemon-user-bounces at lemon.cs.elte.hu] On Behalf Of Goldberg, Noam
>> [ngoldber at telcordia.com] Sent: Thursday, May 07, 2009 4:06 PM
>> To: lemon-user at lemon.cs.elte.hu
>> Subject: [Lemon-user] O(1) method to get number of arcs and nodes
>>
>> Could it be that there is no method of SmartDigraph or Graph to get the
>> number of arcs and nodes (e.g., stl like size() method)?
>>
>> Thank you in advance,
>> Noam
>> _______________________________________________
>> Lemon-user mailing list
>> Lemon-user at lemon.cs.elte.hu
>> http://lemon.cs.elte.hu/mailman/listinfo/lemon-user
>> _______________________________________________
>> Lemon-user mailing list
>> Lemon-user at lemon.cs.elte.hu
>> http://lemon.cs.elte.hu/mailman/listinfo/lemon-user
> 
> _______________________________________________
> Lemon-user mailing list
> Lemon-user at lemon.cs.elte.hu
> http://lemon.cs.elte.hu/mailman/listinfo/lemon-user




More information about the Lemon-user mailing list