<｜begin▁of▁sentence｜>### Instruction:
Given a graph with nodes [1, 2, 3], can you set a custom node attribute with colors corresponding to each node, where node 1 is 'red', node 2 is 'green', and node 3 is 'blue'? How would you access and print the attributes for all nodes afterwards?
### Response:
import networkx as nx

# Create a graph
G = nx.Graph()
G.add_nodes_from([1, 2, 3])

# Set a custom node attribute called 'color'
node_colors = {1: 'red', 2: 'green', 3: 'blue'}
nx.set_node_attributes(G, node_colors, 'color')

print(G.nodes(data=True))
<|EOT|>
