n = g.vcount()
common_neis = zeros(n, n)
for v in range(g.vcount()):
    neis = g.neighbors(v)
for u, w in combinations(neis, 2):
    common_neis[u, w] += 1
common_neis[w, u] += 1
Common neighbors and preferential attachment score matrixes using igraph for python