<｜begin▁of▁sentence｜>### Instruction:
Given a graph whose edge set is [('A', 'B', {'weight': 2}), ('A', 'C', {'weight': 3}), ('B', 'C', {'weight': 1}), ('C', 'D', {'weight': 4})], can you generate the graph's adjacency matrix as a NumPy array using the to_numpy_array function in NetworkX? Please ensure to include a custom nodelist that defines the order of nodes in the matrix and use the 'weight' attribute for the edges.
### Response:
import networkx as nx

# Create a graph
G = nx.Graph()
G.add_edge('A', 'B', weight=2)
G.add_edge('A', 'C', weight=3)
G.add_edge('B', 'C', weight=1)
G.add_edge('C', 'D', weight=4)

# Get the adjacency matrix of the graph as a NumPy array
adj_matrix = nx.to_numpy_array(G, nodelist=['A', 'B', 'C', 'D'], weight='weight')

print(adj_matrix)
<|EOT|>
