[Top][All Lists]
[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: |
Tue, 28 Apr 2009 21:57:48 -0500 |
On Tue, Apr 28, 2009 at 5:21 AM, Gábor Csárdi <address@hidden> wrote:
> Paul,
>
> I mean something like this:
>
> igraph_empty(&graph, nodes, IGRAPH_DIRECTED);
> igraph_adjlist_init(&graph, &myAList, IGRAPH_OUT);
>
> for (i=0; i<nodes; i++) {
> igraph_vector_t *neis=igraph_adjlist_get(&myAList, i);
> /* put the neighbors if node 'i' into neis here, by using
> igraph_vector_push_back, or some other method */
> }
>
> igraph_adjlist(&graph2, &myAList, IGRAPH_DIRECTED, /*duplicate*/=0);
> igraph_destroy(&graph);
> igraph_adjlist_destroy(&myAList);
>
> You did kind of the same, but I am not sure why you need
> igraph_update. If you put the neighbors of a vertex into a vector, you
> can just put them into the adjacency list immediately.
>
Ach! I still don't understand.
How do I get a vector of reals into the adjlist vector neis?
int M = 7;
double edge[] = {1,2,3,4,5,7,8}
for (i=0; i<nodes; i++) {
igraph_vector_t *neis=igraph_adjlist_get(&myAList, i);
for (j=0; j <M; j++) {
igraph_vector_push_back(neis, edge[j] );
}
}
Inefficient, right?
This calls the memory allocator 1 time for each individual item being added.
I am looking for an igraph function with a declaration like
int igraph_vector_real_copy(igraph_vector_t *v,
real *data, long int length);
pj
--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas