I have a graph which has nodes/edges. I assigned the nodes some attributes
[(1, {'node_rx_signal': 0}),
(2, {'node_rx_signal': 0}),
(3, {'node_rx_signal': 1}),
(4, {'node_rx_signal': 0}),
(5, {'node_rx_signal': 1}),
(6, {'node_rx_signal': 0}),
(7, {'node_rx_signal': 0}),
(8, {'node_rx_signal': 0})]
e.g its is to signify that some nodes have this attribute set to 0 while others don't.
With the help of for loop with an If condition I want to carry out a task but I can not seem to access the nodes with 'node_rx_signal' == 1
.
nx.set_node_attributes(T1,values=0,name='node_rx_signal')
T1.nodes[3]['node_rx_signal'] = 1
T1.nodes[5]['node_rx_signal'] = 1
for n, data in T1:
if T1[n][data]==1:
print(T1.node)
print([n for n in T1.neighbors(n)])
else:
pass
Something along these lines.