[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Python igraph Documentation and Examples
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Python igraph Documentation and Examples |
Date: |
Wed, 10 Dec 2008 11:12:49 +0000 |
Dear Lorenzo,
(1) Generate a graph with a given distribution of degrees P(k)
This should be something like:
degrees = [your list of degrees for each vertex]
g = Graph.Degree_Sequence(degrees, method="vl")
Note that degdist contains the actual degrees, not the distribution,
so you will have to generate the appropriate list of degrees (and hope
that it's realizable). method="vl" generates simple graphs with the
method of Viger and Latapy, but it takes more time. method="simple" is
a much simpler method that does not guarantee that you won't get
multiple edges.
(2) See what happens if for instance I disconnect certain components
of a graph
You can remove edges and nodes by g.delete_edges() and
g.delete_vertices() if g is a Graph object. Just remove them and
recalculate your measures, whatever they are.
(3) Calculate the minimum distance between some edges
Well, if those edges are A-B and C-D, calculate the minimum distance
between A-C, A-D, B-C and B-D and take the minimum of them. Distance
calculations can be done by Graph.shortest_paths(vs), where vs is a
list of start vertices and it will return a list for each start vertex
you gave, containing the shortest paths from that vertex to ALL other
vertices.
Is there any place online where I can find them? In a sense, I am
looking for a Python igraph cookbook.
Once I came up with the idea of collecting igraph-related code
snippets in snipplr.com, then I abandoned it thinking that there will
be no real demand for that. So currently there's only one such snippet
there:
http://snipplr.com/view/9914/calculating-assortativity-coefficient-in-igraph/
Anyway, seeing that the demand grows, I might be reconsidering the
idea ;)
Last question: it seems to be that the documentation for the R igraph
package is more substantial (and also has more examples) than the one
for the python binding. Is there a reason for this?
Yes, sheer laziness on my side :( More precisely it's a general lack
of spare time rather than laziness. The good news is that I plan to
release a proper tutorial for igraph's Python interface after the
Christmas holiday (assuming that I will have enough time to finish it
during the holiday).
--
Tamas