A diagram is a functor I am trying to understand the definition of diagrams as functors in category theory. Following nLab, a diagram $D$ of shape $\mathcal I$ in category $\mathcal C$ is a functor $D:\mathcal I\rightarrow \mathcal C$, where $\mathcal I$ is a small category. Let's consider the following cospan:
$$\begin{array}{} && X \\ && \big\downarrow{g} \\  Y & \underset{f}\longrightarrow & Z \end{array}$$
Let $D$ be a functor that maps $X\mapsto C,Y\mapsto C,Z\mapsto C',f\mapsto h,g\mapsto h$ and identities in the obvious way. This yields the following diagram in $\mathcal C$:
$$C\underset{h}\longrightarrow C' $$
Identities are preserved, and there are no composites. We have $$D(f:Y\rightarrow Z)=D(f):D(Y)\rightarrow D(Z)=h:C\rightarrow C'$$ and $$D(g:X\rightarrow Z)=D(g):D(X)\rightarrow D(Z)=h:C\rightarrow C'$$ as required.
Still, this functor does not preserve the shape of $\mathcal I$. It is no longer a cospan. Or is there some other sense in which the diagram $D$ has the shape of $\mathcal I$?
 A: It does have the required shape:
$\require{AMScd}$
\begin{CD}
     @. C\\
    @. @VV h V\\
    C @>>h> C'
\end{CD}
You can think of an indexed family $\{x_i\}_I$, which is a function $x\colon I\to X$. Let's say $I = 2$ and you have $x\colon 2\to X$. Then, $\{x_0,x_1\}_2$ is a family indexed by $2$ even when $x_0 = x_1$.
It's the same with the above diagram, it is indexed by $\mathcal I$ even though the arrows are the same morphism.
Actually, such diagrams are useful. One example is that you can say $h$ is monomorphism if and only if
\begin{CD}
    C @>\operatorname{id}_C>> C\\
    @V \operatorname{id}_C V V @VV h V\\
    C @>>h> C'
\end{CD}
is Cartesian square (pullback).
A: A functor $I \to C$ clearly maps to some shape of $I$ in $C$ : just draw, in $C$, where each object and morphism goes. Here is your shape. You might loose information, just like a function always "loose" information, but the picture you get respects (and not preserve) the structure you had in $I$.
One way it maximally does not preserve the structure (yet still respects it in the destruction) is in the functor mapping any category to the $1$ category.
By the way, you want to loose information, otherwise, you would have little choice. or you could not be amazed when you have functor which actually is an isomorphism when it's not evident it preserve information ;)
Conversely, a shape in $C$ is also "a" functor, from the trivial category made of your shape.
But, precomposition with any functor (full and surjective) on objects will also yield the same shape.
So there are infinitely many such functors, but they all will factor out through this terminal functor, which starts from the "trivial" category, which looks like the drawn shape and only has that, and goes to $C$, which might have many more objects and morphisms.
