def test_nearest_neighbor(abcde):
    r"""Testing structure.

    Example::

        a1  a2  a3  a4  a5  a6  a7 a8  a9
         \  |  /  \ |  /  \ |  / \ |  /
            b1      b2      b3     b4

    Want to finish off a local group before moving on.
    This is difficult because all groups are connected.

    """
    a, b, c, _, _ = abcde
    a1, a2, a3, a4, a5, a6, a7, a8, a9 = (a + i for i in "123456789")
    b1, b2, b3, b4 = (b + i for i in "1234")

    dsk = {
        b1: (f,),
        b2: (f,),
        b3: (f,),
        b4: (f,),
        a1: (f, b1),
        a2: (f, b1),
        a3: (f, b1, b2),
        a4: (f, b2),
        a5: (f, b2, b3),
        a6: (f, b3),
        a7: (f, b3, b4),
        a8: (f, b4),
        a9: (f, b4),
    }

    o = order(dsk)

    assert 3 < sum(o[a + i] < len(o) / 2 for i in "123456789") < 7
    assert 1 < sum(o[b + i] < len(o) / 2 for i in "1234") < 4
    assert o[min([b1, b2, b3, b4])] == 0
Testing structure.

    Example::

        a1  a2  a3  a4  a5  a6  a7 a8  a9
         \  |  /  \ |  /  \ |  / \ |  /
            b1      b2      b3     b4

    Want to finish off a local group before moving on.
    This is difficult because all groups are connected.

    
tests/core/serve/test_dag/test_order.py