[Top][All Lists]

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

Re: [igraph] Help with Weighted_Adjacency

From: Tamás Nepusz
Subject: Re: [igraph] Help with Weighted_Adjacency
Date: Wed, 25 Jun 2014 22:23:26 +0200

> Thank you very much.
> Just one more thing please... pagerank works ok, but I get an error with
> evcent:
> AdjacencyMatrix3= [[0,2,1,0,0,0,0,0,0], [1,0,5,8,0,0,0,0,0],
> [0,7,0,1,0,0,0,0,0], [1,0,8,0,1,0,0,0,0], [0,0,0,8,0,1,0,0,0],
> [0,0,0,0,1,0,0,0,1], [0,0,0,0,0,1,0,0,1], [0,0,0,0,0,1,1,0,0],
> [0,0,0,0,0,1,0,10,0]]
> graph3 = Graph.Weighted_Adjacency(AdjacencyMatrix3, mode = 'directed', attr
> = 'weight')
> evcentr3 = graph3.evcent(weights=graph3.es["weight"])
> TypeError: sequence elements must be integers
There is a bug in evcent so it accepts integer weights only. 
graph3.es["weight"] contains floating point numbers, so that's why you see this 
error. If all your weights are integers, you can convert them explicitly to 
integers (since Graph.Weighted_Adjacency casts them into floats):

graph3.es["weight"] = [int(x) for x in graph3.es["weight"]]

If your weights are not integers, just multiply them by, say, 10000000, before 
casting them to integers because eigenvector centrality does not care about the 
absolute values of the weights, only the relative proportions.


reply via email to

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