I need to merge some info from different datasets to build a dataset that includes nodes, edges and nodes' attributes.
The first dataset (df1) is something like this:
Node Edge
A B
A D
B N
B A
B X
S C
The second dataset includes unique nodes and their properties:
Node Attribute
A -1
B 0
C -1.5
D 1
...
N 1
...
X 0
Y -1.5
W -1.5
Z 1
I would like to create a graph using the links as in the first dataset (df1), coloring nodes based on the attribute values:
- if -1.5 then grey
- if -1 then red
- if 0 then orange
- if 1 then yellow
- if 1.5 then green
For building the graph I can use
G = nx.from_pandas_edgelist(edges, source='Node', target='Edge')
Then I will need to set the above rules for assigning the color and add them as attribute of nodes. My question is on how I can include these rules as node's attribute.
