# Revision history [back]

### How to find the sum weight on a vertex

Hi I want to define a random labeling on edges of a graph (without duplicate labels ) and then find the sum of the weights of incident edges to each vertex. Here is code I wrote:

n=[]
import random
W=random.sample(G.num_edges(),G.num_edges())
w_edges = [(E[i][0], E[i][1], W[i]) for i in xrange(q)]
for i in G.vertex_iterator():
x=sum(W[k] for k in G.neighbor_iterator(i))
n.append(x)


But I receive some errors. I'll be happy if you can help me.