'Returns a dictionary mapping triangles to their minimal sizes.
The minimal size of a triangle is the sum of maximal lengths
of morphisms associated to the sides of the triangle.  The
length of a morphism is the number of components it consists
of.  A non-composite morphism is of length 1.
Sorting triangles by this metric attempts to address two
aspects of layout.  For triangles with only simple morphisms
in the edge, this assures that triangles with all three edges
visible will get typeset after triangles with less visible
edges, which sometimes minimises the necessity in diagonal
arrows.  For triangles with composite morphisms in the edges,
this assures that objects connected with shorter morphisms
will be laid out first, resulting the visual proximity of
those objects which are connected by shorter morphisms.'

@staticmethod
def _compute_triangle_min_sizes(triangles, edges):

    triangle_sizes = {}
    for triangle in triangles:
        size = 0
        for e in triangle:
            morphisms = edges[e]
            if morphisms:
                size += max((DiagramGrid._morphism_length(m) for m in morphisms))
        triangle_sizes[triangle] = size
    return triangle_sizes
