igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] New user of igraph in C. Basic question about data importa


From: Paul Johnson
Subject: Re: [igraph] New user of igraph in C. Basic question about data importation
Date: Mon, 27 Apr 2009 22:15:09 -0500

On Sun, Apr 26, 2009 at 2:44 AM, Gábor Csárdi <address@hidden> wrote:
> Paul,
>

> So if you know all the connections, then it is better to create the
> graph in one go. To avoid creating a big vector, you can create a
> graph with the correct number of vertices, but no edges, transform it
> to an igraph_adjlist_t (not surprisingly, an adjacency list), and then
> edit the vectors in the adjacency list, and finally create a final
> graph from the adjlist. This takes just as much memory as a the long
> vector, in fact, even more, but perhaps the code would be more
> readable.
>
>
> --
> Gabor Csardi <address@hidden>     UNIL DGM
>

Dear Gabor:

Thanks very much for the quick answer. I think I understand.  I've
made a small test program to see if I understand. It seems to work!
But I don't know if I'm doing this fully properly.  Would you care to
comment on my effort?  The file is attached.

Mainly I'm curious about the most efficient way to take the edges from
my program and import them into the adjlist vectors.  If 'edges2' is a
vector of doubles I create, is this an efficient way to take the
values into the adjacency list?


     igraph_vector_view(&v, edges2, sizeof(edges2)/sizeof(double));
     exampleAVector = igraph_adjlist_get(&myAList, 1);
     igraph_vector_update(exampleAVector, &v);

I have to iterate through my objects to create that real vector, so I
could skip that step and just put values into "exampleAVector" one at
a time with  your vector macro, but my guess is that
"igraph_vector_update" is better. ?


I wish your igraph_vector objects had a "print" method to dump their
contents onto the screen or to a file.  Since the results of the
diagnostics (e.g., triad census) are vectors, that would be
convenient!  If I write something up, will you accept patches?

pj

-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

Attachment: ig5-1.c
Description: Text Data


reply via email to

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