Reading "P. Smith, Category Theory - A Gentle Introduction". There it is defined
A category diagram commutes if for any two directed paths along edges in the diagram from a node X to the node Y, the composite arrow along the first path is equal to the composite arrow along the second path.
Let's assume we have the following diagram:
A ---f---> B
\ |
\ |
k g
\ |
\ |
\/ \/
C
Now, let's check if this diagram commutes. I will instantiate the above definition with the nodes A and C:
A category diagram commutes if for any two directed paths along edges in the diagram from the node
Ato the nodeC, the composite arrow along the first path is equal to the composite arrow along the second path.
We have two paths:
path_1 := A --f--> B --g--> C
path_2 := A --k--> C
And the corresponding composites:
composite along path_1 := g . f
composite along path_2 := k
So we have to show, that those two composites are equal, i.e., g . f = k.
I'd like to understand intuitively, why can I reason that those two composites are equal?
In the article it is stated, "the diagram commutes by the definition of composition".
OK, I know the fact, that due to cod f = dom g we know that there must exist the composite of f with g: g . f :: A -> C but how do I know that this composite is equal to k (which is the condition for the diagram to commute). In other words, why can't there be a "function" k from A to C not being equal to the "function" g .f?
Update as reply to Matthew Towers and Peter Smith (2018-11-25):
Matthew Towers and Peter Smith, please don't get me wrong here. I guess all this is very trivial to all of you. I just wanted to have a pragmatic (algorithmic) way of testing if a diagram commutes.
So, is the following correct:
If one wants to check if a diagram commutes, then for /all/ paths from a node X to a node Y the respective composites have to be checked for equality.
Right?
If yes, let me try to apply this to the first triangle of
the triangle made by the arrows $g \circ f\colon A \to C$, and $f\colon A\to B$ and $g\colon B \to C$, and then also the triangle made by the arrows $h \circ g\colon B \to D$, and $g\colon B \to C$ and $h\colon C \to G$.
Please let me also re-ref your (adapted) definition:
A category diagram commutes if for any two directed paths along edges in the diagram from a node X to a node Y, the composite arrow along the first path is equal to the composite arrow along the second path.
So, with $X = A$ and $Y = C$ we have the following paths:
p1 := A --f--> B --g--> C
p2 := A --g∘f--> C
And the corresponding composites along those paths:
c1 along p1 := g∘f
c2 along p2 := g∘f
(Matthew Towers and Peter Smith: Is c2, the correct composite along the second path (even the path consists of only one edge)?)
So, in order to check if the first triangle commutes, for /all/ paths from A to C we have to check the respective composites are equal. In this case, there are only two paths, so we have to check $c1 = c2$, which is true.
The set of arrows $\text{hom}(A,C)$ is a set and asking if two elements of this set are equal or not has sense. But of course a priori you don't know if two elements are equal or not, it depends on the particular case.