igraph and usage of Read(klass, f, format=None, *args, **kwds) question

Ian Kelly ian.g.kelly at gmail.com
Wed Apr 4 16:40:22 EDT 2012


On Tue, Apr 3, 2012 at 9:45 PM,  <ishwar.rattan at gmail.com> wrote:
> I have a file with with adjacency list of an undirected graph one vertex list per input line [0 1, 1 2 3, 2 1, 3 1] assume a newline for commas (file is named adjl.txt). Can some one give an example of loading this into graph of 4 vertices?
>
> import igraph
> g = igraph.Graph()
> g.Read("adjl.txt", "edgelist")
>   does not work..

"does not work" is not very useful in figuring out what the problem
is.  What actually happens, versus what you were expecting?  Was there
an error message?

Looking at the documentation, it appears that Read is a class method,
not an instance method -- it is agnostic to the instance g and only
cares that it is a member of Graph.  The docs do not specify this, but
I would guess that it probably returns a newly created instance of
Graph.  The correct way to call it then would probably be something
like:

g = igraph.Graph.Read("adjl.txt", "edgelist")



More information about the Python-list mailing list