Select network nodes with a given attribute value

Python <= 2.7:

According to the documentation try:

nodesAt5 = filter(lambda (n, d): d['at'] == 5, P.nodes(data=True))

or like your approach

nodesAt5 = []
for (p, d) in P.nodes(data=True):
    if d['at'] == 5:
        nodesAt5.append(p)

Python 2.7 and 3:

nodesAt5 = [x for x,y in P.nodes(data=True) if y['at']==5]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)