igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] elementary community_fastgreedy()


From: Tamas Nepusz
Subject: Re: [igraph] elementary community_fastgreedy()
Date: Wed, 29 Jun 2011 13:15:29 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10

> i am beginner for igraph under python and my problem how can i add weights
> to my edges?.
Like this:

graph.es["weight"] = [1,2,3,4,5]

This assigns weights 1, 2, 3, 4 and 5 to a graph with five edges. Of course
the length of the list must match the number of edges in your graph.

If you want to look it up in the API documentation yourself, look for the
documentation of the EdgeSeq class -- graph.es is basically the edge
sequence of the entire graph and it is an instance of EdgeSeq.

> And community_fastgreedy() how is it consider weights
> is high values indicates strong bonds or is it distance?
High values indicate strong bonds; in other words, weights represent
similarities, not distances.

> myfirst column is node 1 second column is node2 and third column is for
> bond strength in a txt format
This is the NCOL format in igraph lingo, so you can simply do this to load
your graph:

import igraph
g = igraph.load("my_graph.txt", format="ncol", directed=False)

This will automatically assign the weights to your edges, so you can use
graph.es["weight"] to query them.

Finally, you can use the weights=... keyword argument of
Graph.community_fastgreedy() to specify the weights:

cl = g.community_fastgreedy(weights="weight")

-- 
Tamas



reply via email to

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