igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] equivalent of BFS iterator in igraph C?


From: Tamas Nepusz
Subject: Re: [igraph] equivalent of BFS iterator in igraph C?
Date: Fri, 18 Nov 2011 14:06:50 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1

Hi Galen,

The BFS iterator in Python is implemented in the glue layer between the C
core of igraph and Python, so it hasn't got any corresponding function in
the C layer. The C core has a function called igraph_bfs, but it has been
marked as "internal" up to the current stable version (0.5.4).

In igraph 0.6, we have decided to implement igraph_bfs "properly", so we
extended its interface a bit and added it to the set of public function.
>From igraph 0.6, igraph_bfs allows one to call a callback function for every
node visited by the BFS traversal. When the callback returns a non-zero
value, the traversal will be terminated. So, if you wish to interrupt the
BFS after a pre-defined number of nodes have been reached, you should try
upgrading to igraph 0.6 and use igraph_bfs from there.

By the way, the source code of igraph_bfs is to be found in src/visitors.c
in the 0.6 branch, so you can simply rip it off and add it to your own
program if you do not wish to upgrade to 0.6 (since it is the development
version and is not tested thoroughly yet). Just make sure you rename it to
something else, otherwise it would conflict with the (internal) igraph_bfs
function in 0.5.4. The source code is here:

http://bazaar.launchpad.net/~igraph/igraph/0.6-main/view/head:/src/visitors.c

You might also need some declarations from igraph_visitor.h:

http://bazaar.launchpad.net/~igraph/igraph/0.6-main/view/head:/include/igraph_visitor.h

Best,
Tamas


On 11/18/2011 01:39 AM, Galen Wilkerson wrote:
> Hi,
> 
> I am trying to BFS from a source node, but stop when reaching a certain
> number of nodes.
> 
> I can do this easily in Python with igraph, but am not sure how this will
> work in the C version.
> 
> thanks for help.
> G
> 
> 
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help



reply via email to

[Prev in Thread] Current Thread [Next in Thread]