def edges(matrix):
    """
    Function returning sorted list of edge pairs.
    Parameters
        ----------
        matrix: Pandas DataFrame
            Adjacency matrix of graph structure to derive list of pairs from.
    """
    raw_edges = matrix.unstack()  # series of raw edge pairs
    edges_ord = raw_edges.sort_values(
        kind="mergesort")  # edge pairs by distance
    pairs = edges_ord[edges_ord != 0].index.tolist()  # remove non-edges
    return pairs