Replies: 1 comment 2 replies
-
It's just a python dictionary underneath, so you are free to use anything hashable as the name of the attribute and it can hold strings as the value just fine. Depends on what you want to do with the attributes.
I guess any mapping-like thing would work here? What is the use case? Something like color_map = {'red': 1, 'green': 2, 'black': 3}
def encode(color):
return color_map[color] would work just fine? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have some problems using NetworkX.
I have some nodes, each node has some attributes and attribute values (For example, name = "Jame").
When we create a graph using the following codes, shouldn't we encode the attribute value ("green") to numbers before assigning it to the node?
I want to encode values. What encodings can I use?
Should the name of attributes encoded too?
G=nx.Graph()
G.add_nodes_from([ (4, {"color": "red"}), (5, {"color": "green"})
Beta Was this translation helpful? Give feedback.
All reactions