[Top][All Lists]

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

Re: [igraph] find highest degrees

From: Gábor Csárdi
Subject: Re: [igraph] find highest degrees
Date: Sat, 20 Feb 2010 10:35:14 +0100

On Fri, Feb 19, 2010 at 11:36 PM, John Lapeyre <address@hidden> wrote:
>> I thought about adding an option to return the degrees themselves, but
>> I couldn't find a way to do that without putting a conditional in the
>> innermost loop..
>  No thats not correct. But, it would be a good thing to
> pass two pointers, one for the degrees and one for the
> order.  (and either one could be NULL if the user does not
> want it) But igraph_indheap_init_array initializes from a C
> array, not an igraph_vector, so it is not possible to return
> the degrees without an extra copy. It seems like currently
> the only way to do this within heap.c is to access the data
> in the vector struct, which goes around the vector interface.

VECTOR(v) gives you the underlying C array of a VECTOR.

> But a function in vector.c like this might be useful:
>  vector_copy_data(igraph_vector_t *v, igraph_real_t *data, size_t n)

There is a function called igraph_vector_copy_to(), that does almost
the same, the only difference is that it copies the whole vector.

Btw. I think it is simpler to sort the two vectors and then merge
them. This involves copying them, of course, but the heap approach
copies as well, and I guess that the C library quicksort will be
faster than the heap-sort. Even if it is not faster, it is surely
easier to implement, you just need to

1. copy the two vectors
2. sort them
3. merge them (this needs a vector_union_sorted function), but this is
trivial to write.


> It would use memcpy to copy n bytes FROM the array in
> the vector struct TO memory starting at the location given by data.
> This would allow a function like this
>  igraph_indheap_init_vector, that initializes the heap from
> data in a vector.
> John
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help

Gabor Csardi <address@hidden>     UNIL DGM

reply via email to

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