igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] igraph.community_fastgreedy method and isolated vertices


From: Tamas Nepusz
Subject: Re: [igraph] igraph.community_fastgreedy method and isolated vertices
Date: Thu, 7 Aug 2008 16:46:46 +0200

Hi,

its falling over. I suspect its because of isolated vertices (not
connected to any other nodes) in my graph.
Graph.community_fastgreedy used to fail when executed on non-simple graphs or graphs with isolated vertices. Theoretically this bug is corrected in the dev tree (and will be corrected in the upcoming 0.5.1). Anyway, if you could send me an example graph so I could test it in the dev tree, that would be great.

I tried to remove them using the following code
Try this:

isolates = g.vs.select(_degree=0)
g.delete_vertices(isolates)

Your code didn't work because igraph reindexes the vertices when you delete one. Alternatively, you can collect isolate vertex indices first and delete them in one step:

isolates = [index for index, degree in enumerate(g.degree()) if degree == 0]
g.delete_vertices(isolates)

--
T.





reply via email to

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