def _triangles(dg):
    """
    Return a list of all oriented triangles in the digraph ``dg``.

    EXAMPLES::

        sage: from sage.combinat.cluster_algebra_quiver.mutation_type import _triangles
        sage: Q = ClusterQuiver(['A',3])
        sage: _triangles(Q.digraph())
        []
        sage: Q.mutate([0,1])
        sage: _triangles(Q.digraph())
        [([(2, 0), (0, 1), (1, 2)], True)]
        sage: Q2 = ClusterQuiver(['A',[1,2],1])
        sage: _triangles(Q2.digraph())
        [([(1, 2), (1, 0), (2, 0)], False)]
        sage: Q2.mutate(2)
        sage: _triangles(Q2.digraph())
        [([(1, 0), (0, 2), (2, 1)], True)]
    """
    E = dg.edges(labels=False)
    V = dg.vertices()
    trians = []
    flat_trians = []
    for e in E:
        v1, v2 = e
        for v in V:
            if not v in e:
                if (v, v1) in E:
                    if (v2, v) in E:
                        flat_trian = sorted([v,v1,v2])
                        if flat_trian not in flat_trians:
                            flat_trians.append( flat_trian )
                            trians.append( ( [(v,v1),(v1,v2),(v2,v)], True ) )
                    elif (v, v2) in E:
                        flat_trian = sorted([v,v1,v2])
                        if flat_trian not in flat_trians:
                            flat_trians.append( flat_trian )
                            trians.append( ( [(v,v1),(v1,v2),(v,v2)], False ) )
                if (v1, v) in E:
                    if (v2, v) in E:
                        flat_trian = sorted([v,v1,v2])
                        if flat_trian not in flat_trians:
                            flat_trians.append( flat_trian )
                            trians.append( ( [(v1,v),(v1,v2),(v2,v)], False ) )
                    elif (v, v2) in E:
                        flat_trian = sorted([v,v1,v2])
                        if flat_trian not in flat_trians:
                            flat_trians.append( flat_trian )
                            trians.append( ( [(v1,v),(v1,v2),(v,v2)], False ) )
    return trians