igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] simple question


From: costa basil
Subject: Re: [igraph] simple question
Date: Mon, 15 Apr 2013 10:24:59 -0700

Thanks a lot for the explanations. I am going to give it a try in the next few days.


On Mon, Apr 15, 2013 at 1:09 AM, Tamas Nepusz <address@hidden> wrote:
Hi,

>  Let's say the vertexes are from 1 to N,
igraph vertex and edge indices are zero-based (which is the standard
convention in C anyway so I guess this did not strike you as a surprise ;)).

> the edges, but I don't understand what is the format that igraph accepts.
> For instance, one way would be to put all the edges in a huge array of pairs
> (X, Y) where there is an edge from X to Y. The array would contain: 0, 1, 0,
> 2, 1, 3, 1, 4 etc where (0, 1), (0, 2), (1, 3), (1, 4)  etc are all edges.
This is the format that igraph requires. Use an igraph_vector_t to store the
edge list and then call igraph_create to construct your graph:

http://igraph.sourceforge.net/doc/html/ch09s01.html#igraph_create

An alternative way you could use is an adjacency list where you will
basically have 80 million vectors, and the ith vector stores the neighbors
of vertex i. The constructor to use is igraph_adjlist:

http://igraph.sourceforge.net/doc/html/ch09s01.html#igraph_adjlist

igraph_adjlist requires you to use our igraph_adjlist_t data structure,
though. You have to construct an empty adjacency list first with
igraph_adjlist_init_empty -- this also created all the 80 million vectors
for you. You can then get the i-th vector using igraph_adjlist_get and add
new neighbors to it using igraph_vector_push_back. Once you set up the
adjacency list, you can call igraph_adjlist to turn that into an igraph_t
(which is an indexed edge list by the way, but this is an implementation
detail that you shouldn't care about). Finally, you can throw the
igraph_adjlist_t away by calling igraph_adjlist_destroy. Relevant links from
the documentation:

http://igraph.sourceforge.net/doc/html/igraph-Adjlists.html
http://igraph.sourceforge.net/doc/html/igraph-Vectors.html

--
T.

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