(V, E)
return h
Compute the diameter of a mesh.

    Parameters
    ----------
    V : ndarray
        nv x 2 list of coordinates

    E : ndarray
        ne x 3 list of vertices

    Returns
    -------
    h : float
        maximum diameter of a circumcircle over all elements
        longest edge

    Examples
    --------
    >>> import numpy as np
    >>> dx = 1
    >>> V = np.array([[0,0], [dx,0], [0,dx], [dx,dx]])
    >>> E = np.array([[0,1,2], [2,3,1]])
    >>> h = diameter(V, E)
    >>> print(h)
    1.4142135623730951
Compute the diameter of a mesh.
Compute the diameter of a mesh .
def diameter(V, E):
    """Compute the diameter of a mesh.

    Parameters
    ----------
    V : ndarray
        nv x 2 list of coordinates

    E : ndarray
        ne x 3 list of vertices

    Returns
    -------
    h : float
        maximum diameter of a circumcircle over all elements
        longest edge

    Examples
    --------
    >>> import numpy as np
    >>> dx = 1
    >>> V = np.array([[0,0], [dx,0], [0,dx], [dx,dx]])
    >>> E = np.array([[0,1,2], [2,3,1]])
    >>> h = diameter(V, E)
    >>> print(h)
    1.4142135623730951

    """
    if not isinstance(V, np.ndarray) or not isinstance(E, np.ndarray):
        raise ValueError('V and E must be ndarray')

    if V.shape[1] != 2 or E.shape[1] != 3:
        raise ValueError('V should be nv x 2 and E should be ne x 3')

    h = 0
    I = [0, 1, 2, 0]
    for e in E:
        hs = np.sqrt(np.diff(V[e[I], 0])**2 + np.diff(V[e[I], 1])**2)
        h = max(h, hs.max())
    return h
def diameter ( V , E ) : if not isinstance ( V , np . ndarray ) or not isinstance ( E , np . ndarray ) : raise ValueError ( 'V and E must be ndarray' ) if V . shape [ 1 ] != 2 or E . shape [ 1 ] != 3 : raise ValueError ( 'V should be nv x 2 and E should be ne x 3' ) h = 0 I = [ 0 , 1 , 2 , 0 ] for e in E : hs = np . sqrt ( np . diff ( V [ e [ I ] , 0 ] ) ** 2 + np . diff ( V [ e [ I ] , 1 ] ) ** 2 ) h = max ( h , hs . max ( ) ) return h