hi
this code is in python and does have some problem. hope u can help me to solve it
def propagateLabel(G):
visitSequence = random.sample(G.nodes(),len(G.nodes()))
for i in visitSequence:
node = G.node[i]
label = node[“label”]
dict = getMaxNeighborLabel(G, i)
if(not dict.has_key(label)):
newLabel = dict.keys()[random.randrange(len(dict.keys()))]
node["label"] = newLabel
# dict.keys() -> list of dict's keys
the part which create an error:
random.randrange(len(dict.keys()))
and error is this:
191 return self._randbelow(istart)
192 return _int(self.random() * istart)
–> 193 raise ValueError, "empty range for randrange()"
194
195 # stop argument supplied.
ValueError: empty range for randrange()
can anybody help me?
this label propagation is for LPA label propagation algorithm. this code i found in Github.