[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Re: shortest path length
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Re: shortest path length |
Date: |
Thu, 18 Jun 2009 13:01:41 +0100 |
User-agent: |
Mutt/1.5.17 (2007-11-01) |
Hi,
OK, I really had to sit down and test what I wrote ;) See the
attachment, this one surely works on my computer.
--
Tamas
On Thu, Jun 18, 2009 at 12:22:54PM +0100, Tamas Nepusz wrote:
> Hi,
>
> Whoops. Looks like you should prepare the result vector in advance so it
> has exactly as many initialized vectors as needed. Since you are asking
> for the shortest paths for a single target vertex, you should do this:
>
> igraph_t graph;
> igraph_vector_ptr_t result_paths;
> igraph_vector_t *result_path;
> igraph_integer_t from_node;
> igraph_integer_t to_node;
>
> igraph_vector_ptr_init(&result_paths, 1);
> // The next statement is a shortcut macro for setting an element of an
> // igraph vector
> VECTOR(*result_paths)[0] = result_path;
> from_node = 10;
> to_node = 1000;
> igraph_get_shortest_paths(&graph, &result_paths, from_node,
> igraph_vss_1(to_node), IGRAPH_ALL);
> for (i=0; i<igraph_vector_size(result_path); i++) {
> printf("%ld ", (long)igraph_vector_e(result_path, i));
> }
> printf("\n");
> igraph_vector_destroy(result_path); // destroy the path
> igraph_vector_ptr_destroy(result_paths); // destroy the pointer vector
>
> Hope this works,
> --
> Tamas
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
igraph_get_shortest_paths_example.c
Description: Text Data
pgpMnLDZLQf7B.pgp
Description: PGP signature