Python 2.7 still struggles with divisions of integers, which means that 1/2 returns 0 instead of 0.5. To avoid that, just use:
from __future__ import division
Related posts
-
Building a network (Part 1)
Building a similarity network to analyse in Gephi - built for a dataviz competition