def find_neighbors(tri):
    """
    The find_neighbors function performes the listing of all the neighboring
    nodes for each node in the triangulation. It is based on an idea provided
    at stackoverflow about listing the neighboring points of triangulation
    nodes.

    Parameters
    ----------
    tri: scipy.spatial.qhull.Delaunay
            Delaunay triangulation generated from the point_data variable.

    Returns
    -------
    neighbors: collections.defaultdict
            Sets of neighboring nodes for each node in the triangulation.

    Reference
    ---------
    .. [1] Answers provided by astrofrog and glyg at https://stackoverflow.com/questions/12374781/how-to-find-all-neighbors-of-a-given-point-in-a-delaunay-triangulation-using-sci/17811731.

    See also
    --------
    scipy.spatial: spatial algorithms and data structures.

    scipy.spatial.Delaunay: Delaunay tesselation in N dimensions.

    Usage
    -----
    >>> neighbors = basic_info.find_neighbors(tri)

    """
    from collections import defaultdict
    neighbors = defaultdict(set)
    for simplex in tri.simplices:
        for pid in simplex:
            other = set(simplex)
            other.remove(pid)
            neighbors[pid] = neighbors[pid].union(other)
    for node in range(len(neighbors)):
        len(neighbors[node])
    return neighbors
