igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Sorting vertices by degree with igraph C library


From: Szabolcs Horvát
Subject: Re: [igraph] Sorting vertices by degree with igraph C library
Date: Thu, 22 Mar 2018 22:36:17 +0100

Hello Vincent,

Normally you would have to program this yourself. E.g. you can generate a vector of increasing integers (vertex indices), write a custom comparison function that compares v1 and v2 through degrees[v1] and degrees[v2], then use this to sort the indices (e.g. through the qsort() C standard library function, or much more easily with std::sort() in C++)

Luckily, this is already done in igraph, though not documented. The function is  igraph_vector_qsort_ind()  You'll find its description in the vector.pmt file.

On 22 March 2018 at 20:56, Vincent Beugnet <address@hidden> wrote:
Hello,
I'd like to sort all vertices from a graph (undirected) by decreasing degree and print their ids with this order. But as the vector in igraph_degree is not related with the graph,

The degree vector is related with the graph in that the degree of the nth vertex is the nth entry in the vector.
 
I don't know how to get the ordered ids. Can someone help me ?

Thanks

P.S: I'm using the C library

_______________________________________________
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]