How to verify commutativity of a diagram?

Let $C$ be a category, and let all objects $X_i, Y_j$ belong to $ob(C)$, and morphisms $f_{ij}, h_i, g_{ij}$ be morphisms between them in $C$.

Let us have a diagram then:

How do we verify it's commutative? I mean, the obvious way is to compare all compositions with domain $X_1$ and codomain $Y_4$, but there will be a lot of them.

Can we somehow reduce it to comparing compositions of certain subdiagrams? For example, we have a cube-shaped diagram here. Can we somehow check if the squares are commutative? Will that be enough, or no?

In general, how to deal with such diagrams(not necessarily resembling figures in $\mathbb{R}^3$, just any non-trivial, that is, harder than categorical product/coproduct universal property) diagrams?

• A priori, it's not even enough to check all compositions that go all the way from $X_1$ to $Y_1$ ... that may well work even if one or more of the squares in the diagram doesn't commute; e.g. if $Y_4$ is a terminal object. – Henning Makholm Jun 12 '16 at 21:30
• To check that this diagram is commutative you have to consider all paths in the diagram, not just the ones with domain $X_1$ and codomain $Y_4$. But to prove that it is sufficient to check that the squares commute. – Rob Arthan Jun 12 '16 at 21:31
• @HenningMakholm So we need to check all compositions? With any domain and codomain? – Jxt921 Jun 13 '16 at 0:00
• @RobArthan Do you mean that checking commutativity of squares is sufficient? If that's so, I'll try to prove it. – Jxt921 Jun 13 '16 at 0:02
• Checking the commutativity of the squares is sufficient. (To see this note that the if you have two paths $f$ and $g$ from one object in the diagram to another, then you can transform $f$ into $g$ in steps, where each step only deals with edges of one square.) – Rob Arthan Jun 13 '16 at 0:10