<｜begin▁of▁sentence｜>### Instruction:
Imagine you're working in your garage with a fleet of different vehicles—some red, some blue, green, or yellow. Each vehicle has a relationship with others based on how often they're serviced together, and we quantify this relationship using a numeric 'service hours' value. You're interested in organizing the service records in such a way that you can quickly understand the total service hours shared amongst vehicles of the same color.

Could you figure out how to create a service log matrix where each row and column corresponds to the color of the vehicles, and the entries in the matrix represent the total 'service hours' between vehicles of matching row and column colors?
### Response:
import networkx as nx

# Create a graph
G = nx.Graph()
# Add edges with attributes
G.add_edge(0, 1, color='red', weight=2)
G.add_edge(1, 2, color='blue', weight=3)
G.add_edge(2, 0, color='green', weight=1)
G.add_edge(0, 3, color='red', weight=4)

# Set node attributes
color_map = {0: 'red', 1: 'blue', 2: 'green', 3: 'yellow'}
nx.set_node_attributes(G, color_map, 'color')

# Construct an attribute matrix based on edge weights
M, ordering = nx.attr_matrix(G, edge_attr='weight', node_attr='color', rc_order=['red', 'blue', 'green', 'yellow'])

print('Matrix:\n', M)
print('Ordering:', ordering)
<|EOT|>
