On 05.10.2017 05:15, Snehal Shekatkar wrote:
> The gt.assortativity still seems to be wrong to me. I tried calculating the
> degree-assortativity using gt.assortativity and gt.scalar_assortativity as
> well as manually. My code:
> 
> import graph_tool.all as gt
> 
> # Load a graph
> g = gt.collection.data['karate']
> 
> # Get the adjacency matrix
> adj_mat = gt.adjacency(g).todense()
> 
> # Calculate S values
> S1 = sum([v.out_degree() for v in g.vertices()])
> 
> S2 = sum([(v.out_degree())**2 for v in g.vertices()])
> 
> S3 = sum([(v.out_degree())**3 for v in g.vertices()])
> 
> Se = 0
> 
> for i in range(g.num_vertices()-1):
>     for j in range(i+1, g.num_vertices()):
>         Se += adj_mat[i, j] * g.vertex(i).out_degree() *
> g.vertex(j).out_degree()
> 
> Se *= 2
> 
> 
> # Calculate the assortativity coefficient
> 
> print((S1*Se-S2**2)/(S1*S3-S2**2))
> print(gt.assortativity(g, deg = 'out'))
> print(gt.scalar_assortativity(g, deg = 'out'))
> 
> Results are:
> 
> -0.475613097685
> (-0.07774502579218864, 0.024258508125118667)
> (-0.4756130976846143, 0.1669286053081143)


What is your point?

The first and third values are identical, up to floating point accuracy. The
second value is different, as it should be, since it is a completely
different coefficient.


-- 
Tiago de Paula Peixoto <[email protected]>

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
graph-tool mailing list
[email protected]
https://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to