igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] How to initialize a graph from a (C++) vector of vectors or


From: Gábor Csárdi
Subject: Re: [igraph] How to initialize a graph from a (C++) vector of vectors or from a vector of links
Date: Fri, 28 Feb 2014 09:05:06 -0500

You can just put the weights in another vector, in the same order as the edges. 

In the igraph C library for most functions that support edge weights, you need to pass the them as a separate argument, so keeping them in a separate vector is fine in most cases.

Gabor


On Fri, Feb 28, 2014 at 8:53 AM, Przemyslaw Grabowicz <address@hidden> wrote:
Thanks, that's helpful, but I forgot to mention that my graph is weighted.

In such case, I should create matrix_t with igraph_matrix_init, fill it with my weights, and create a graph using igraph_weighted_adjacency? (Is there any other option?)

Thanks,
Przemek.



On 28/02/2014 00:05, Gábor Csárdi wrote:
There is no easy way, AFAIK. We could have a matrix view, that handles a chunk of memory as a dense matrix, and if the vector of vectors in C++ is a continuous chunk of memory, then there was an easy way.

But right now, just go over the matrix, put the non-zero edges in an igraph_vector_t and call igraph_create().

Gabor


On Thu, Feb 27, 2014 at 5:14 PM, Przemyslaw Grabowicz <address@hidden> wrote:
Dear all,

I know that igraph is written in C. However, what is the easiest way of creating an igraph graph from an adjacency matrix declared as a vector of vectors or from a list of links declared as a vector in C++?

Thanks,
Przemyslaw Grabowicz.


_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help



_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help


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