A group can be thought of as a small category with one object ⁠ x ⁠ in which every morphism is an isomorphism: given such a category, the set Hom ⁡ ⁡ ( x , x ) is a group; conversely, given a group ⁠ G ⁠, one can build a small category with one object ⁠ x ⁠ in which ⁠ Hom ⁡ ⁡ ( x , x ) ≃ ≃ G ⁠. More generally, a groupoid is any small category in which every morphism is an isomorphism. In a groupoid, the set of all morphisms in the category is usually not a group, because the composition is only partially defined: ⁠ f g ⁠ is defined only when the source of ⁠ f ⁠ matches the target of ⁠ g ⁠. Groupoids arise in topology (for instance, the fundamental groupoid) and in the theory of stacks.