def mat2L(edge_matrix):
    """
    Convert a matrix denoting network connectivity (edges or flows) to a list
    denoting edges

    Parameters
    ----------
    edge_matrix   : array
                    where rows denote network edge origins, columns denote
                    network edge destinations, and non-zero entries denote the
                    existence of an edge between a given origin and destination

    Returns
    -------
     edge_list    : list
                    of tuples where each tuple is of the form (o,d) where o is an
                    origin id and d is a destination id

    """
    if len(edge_matrix.shape) != 2:
        raise AttributeError(
            'Matrix of network edges should be two dimensionswith edge origins on one axis and edge destinations on thesecond axis with non-zero matrix entires denoting an edgebetween and origin and destination'
            )
    edge_list = []
    rows, cols = edge_matrix.shape
    for row in range(rows):
        for col in range(cols):
            if edge_matrix[row, col] != 0:
                edge_list.append((row, col))
    return edge_list
