The graph-state stabilizer generators of the path are
and those of the triangle are
Any pair of distinct generators has Pauli factors and in exactly two common positions. Each such position contributes one minus sign on exchange, so the two signs cancel. Thus
This is the general commutativity mechanism for graph-state stabilizers associated with an undirected graph.