In a graph G, there is generally no 'internal' composition of the arrows, so that it is not a category. But the graph can always be extended into a category by adding the paths of the graph.

More precisely, the *category of paths of *G, denoted C(G), is the category whose objects are the vertices of the graph and the links from A to B are the paths (*f*_{1},*f*_{2},...,*f _{n}*) from A to B. The composition of paths is their concatenation: the composite of

(*f*_{1},*f*_{2},...,*f _{n}*): A ® B and (

(*f*_{1},*f*_{2},...,*f _{n} ,g*

As any category K is firstly a graph, we can associate to it the category of its paths C(K). This category has generally more arrows than K, and K can be deduced from C(K) by identification of two paths from A to B which have the same composite in the category K.

Conversely, let us give a graph G and, on the category of its paths C(G), a set of pairs (*c,c'*) of paths of G with the same source and target. Then there is a smallest category C containing G as a sub-graph and in which the *c* and *c'* of each given pair have the same composite. Formally, C is the 'quotient category' of C(G) by the smallest equivalence relation identifying the two paths *c* and *c'* of each pair. We say that C is deduced from the data of *generators* (the arrows of G), and *relations* on them (the pairs of paths which are identified).

Categories modeling natural systems are often constructed in this way. The graph G of generators is a *labeled graph* in the sense that a real number (or a vector), called its *weight,* is associated to each arrow; this weight represents the force and/or the propagation delay with which information are transmitted by the arrow. A path of G is weighted by the sum of the weights of its factors; and the relations identify two paths *c* and *c'* which have the same source, target and weight. The deduced category K has for links from A to B classes of paths from A to B which have the same weight. It is a *weighted category* in the following sense: A category is weighted if it is a labeled graph and if the weight of a composite *fg *is the sum of the weights of *f* and *g*.

A concrete example

The preceding construction will be illustrated by the category of possible itineraries between a set of towns. The labeled graph G has 7 vertices representing the towns: A, A_{1}, A_{2}, A_{3}, A_{4}, A_{5}, B and 10 arrows between them, representing roads, weighted by the length of the road (indicated in the parenthesis):

(*f*_{1},2): A ® A_{1}, (*f*_{2},3): A_{1} ® A_{2},

(*f*_{3},5): A_{2} ® A_{3}, (*f*_{4},4): A_{3} ® B,

(*f*_{5},6): A ® A_{4}, (*f*_{6},8): A_{4} ® B,

(*f*_{7},7): A ® A_{5}, (*f*_{8},7): A_{5} ® B,

(*f*_{9},12): A ® B, (*f*_{10},5): A ® A_{2}

The category of paths C(G) has the same 7 towns as its objects, but it has 20 arrows, obtained by adding to those of G the following paths:

(*f*_{1},*f*_{2}): A ® A_{2}, (*f*_{1},*f*_{2},*f*_{3}): A_{1} ® A_{3},

(*f*_{1},*f*_{2},*f*_{3},*f*_{4}): A ® B, (*f*_{2},*f*_{3}): A_{1} ® A_{3},

(*f*_{2},*f*_{3},*f*_{4}): A_{1} ® B, (*f*_{3},*f*_{4}): A_{2} ® B,

(*f*_{5},*f*_{6}) and (*f*_{7},*f*_{8}): A ® B,

(*f*_{10},*f*_{3}): A ® A_{3}, (*f*_{10},*f*_{3},*f*_{4}): A ® B.

The length of a path is the sum of its factors. The composition of successive paths is the concatenation, for instance:

*f*_{1}.(*f*_{2},*f*_{3}) = (*f*_{1},*f*_{2},*f*_{3}), and (*f*_{1},*f*_{2}).(*f*_{3},*f*_{4}) = (*f*_{1},*f*_{2},*f*_{3},*f*_{4}).

In this category, there exist several links with the same length between two towns.

If a traveller is only interested in the length of the road (which determines the duration of the journey), these paths should be identified. Thus we construct the category C with its generators in G and the relations identifying paths with the same length.

(*f*_{1}, *f*_{2}) = *f*_{10}, (*f*_{1}, *f*_{2}, *f*_{3}) = (*f*_{10}, *f*_{3}),

(*f*_{1}, *f*_{2}, *f*_{3}, *f*_{4}) = (*f*_{5}, *f*_{6}) = (*f*_{7}, *f*_{8}).

C has the same 7 objects, but only 15 arrows, obtained by adding to 5 arrows to G, namely the following weighted composites:

(*f*_{23},8): A_{1} ® A_{3}, (*f*_{34},9): A_{2 }® B,

(*f*_{123},10): A ® A3,(*f*_{234},12): A_{1} ® B,

(*f*_{1234},14): A ® B.

The composition is defined by:

*f*_{1}.*f*_{2} = *f*_{10}, *f*_{1}.*f*_{23} = *f*_{123}, *f*_{1}.*f*_{234} = *f*_{1234} *f*_{2}.*f*_{3} = *f*_{23}, *f*_{2}.*f*_{34} = *f*_{234},

*f*_{3}.*f*_{4} = *f*_{34}, *f*_{5}.*f*_{6} = *f*_{1234}, *f*_{7}.*f*_{8} = *f*_{1234}, *f*_{123}.*f*_{4} = *f*_{1234}

*f*_{10},*f*_{3} = *f*_{123}, *f*_{10}.*f*_{34} = *f*_{1234}, *f*_{123}.*f*_{4} = *f*_{1234}.

(there are no other composites). The length of a composite is the sum of the lengths of its factors. In this category, *f*_{1234} et *f*_{9} are 2 links from A to B in C with different lengths (14 and 12).

The category of neurons

The category of neurons models a neuronal system at a given time *t*. It is constructed by the data of generators and relations.

First we define the labeled graph G of its generators. Its vertices are the neurons; the activity of a neuron N at *t* is determined by its instantaneous frequency of spikes. An arrow from N to N' corresponds to a synapse such that N is the pre-synaptic neuron and N' the post-synaptic neuron. Let us remark that two neurons may be linked by one, several or no arrows. The weight of an arrow from N to N' represents the strength of the synapse, related to the probability that the activity of N be propagated to N' and to the delay of propagation. We adopt the usual convention that the activity of a neuron N is the summation of the activities of the neurons N* _{i}* to which it is linked, pondered by the weights of the synapses linking these N

The category of path C(G) on this graph admits the neurons for its objects, the links from N to N' are the paths formed by successive synapses, and the composition of paths is their concatenation. In this category, two paths from N to N' have the same weight if the activity of N is transmitted to N' in the same way along one of the other of the paths.

The category *Neur* is deduced from the data of G and of the relations on C(G) identifying two paths from N to N' which have the same weight. Thus its objects are still the neurons, but the links from N to N', called *multisynaptic paths*, are classes of paths with the same weight. It is a weighted category.