In category theory, a branch of mathematics, a diagram is the categorical analogue of an indexed family in set theory. The primary difference is that in the categorical setting one has morphisms that also need indexing. An indexed family of sets is a collection of sets, indexed by a fixed set; equivalently, a function from a fixed index set to the class of sets. A diagram is a collection of objects and morphisms, indexed by a fixed category; equivalently, a functor from a fixed index category to some category.
Diagrams are central to the definition of limits and colimits, and to the related notion of cones.
Formally, a diagram of type J in a category C is a (covariant) functor
The category J is called the index category or the scheme of the diagram D; the functor is sometimes called a J-shaped diagram. The actual objects and morphisms in J are largely irrelevant, only the way in which they are interrelated matters. The diagram D is thought of as indexing a collection of objects and morphisms in C patterned on J.
Although, technically, there is no difference between an individual diagram and a functor or between a scheme and a category, the change in terminology reflects a change in perspective, just as in the set theoretic case: one fixes the index category, and allows the functor (and, secondarily, the target category) to vary.
One is most often interested in the case where the scheme J is a small or even finite category. A diagram is said to be small or finite whenever J is.
A morphism of diagrams of type J in a category C is a natural transformation between functors. One can then interpret the category of diagrams of type J in C as the functor category CJ, and a diagram is then an object in this category.