예제 #1
0
def test_example3(alg=1):

    match = [(1, 2), (3, 4), (5, 6), (7, 8)]
    edges = [(1, 2),
             (1, 4),
             (1, 6),
             (3, 4),
             (3, 6),
             (3, 8),
             (5, 6),
             (5, 8),
             (5, 2),
             (7, 8),
             (7, 2),
             (7, 4)]  # yapf: disable

    ref = [[(1, 2), (3, 6), (5, 8), (7, 4)],
           [(1, 2), (3, 4), (5, 6), (7, 8)],
           [(1, 2), (3, 8), (5, 6), (7, 4)],
           [(1, 4), (3, 6), (5, 2), (7, 8)],
           [(1, 4), (3, 6), (5, 8), (7, 2)],
           [(1, 4), (3, 8), (5, 6), (7, 2)],
           [(1, 6), (3, 4), (5, 2), (7, 8)],
           [(1, 6), (3, 4), (5, 8), (7, 2)],
           [(1, 6), (3, 8), (5, 2), (7, 4)]]  # yapf: disable

    ans = uno(edges, verbose=2)
    _check('Example 3a (internal match)', ans, ref)

    ans = uno(edges, verbose=2, match=match)
    _check('Example 3b (provided match)', ans, ref, verbose=2)
예제 #2
0
def test_example4(alg=1):

    # fmt: off
    edges = [(0, 0), (0, 1), (1, 5), (1, 6), (2, 0), (2, 1), (3, 5), (3, 6),
             (4, 2), (4, 3), (5, 2), (5, 3), (6, 4), (6, 7), (7, 4), (7, 7)]
    match = [(0, 0), (2, 1), (4, 2), (5, 3), (6, 4), (3, 5), (1, 6), (7, 7)]

    ref = [
        [(0, 0), (2, 1), (4, 2), (5, 3), (6, 4), (3, 5), (1, 6),
         (7, 7)],  # ----
        [(0, 1), (2, 0), (4, 2), (5, 3), (6, 4), (3, 5), (1, 6),
         (7, 7)],  # *---
        [(0, 0), (2, 1), (4, 3), (5, 2), (6, 4), (3, 5), (1, 6),
         (7, 7)],  # -*--
        [(0, 1), (2, 0), (4, 3), (5, 2), (6, 4), (3, 5), (1, 6),
         (7, 7)],  # **--
        [(0, 0), (2, 1), (4, 2), (5, 3), (6, 7), (3, 5), (1, 6),
         (7, 4)],  # --*-
        [(0, 1), (2, 0), (4, 2), (5, 3), (6, 7), (3, 5), (1, 6),
         (7, 4)],  # *-*-
        [(0, 0), (2, 1), (4, 2), (5, 3), (6, 4), (3, 6), (1, 5),
         (7, 7)],  # ---*
        [(0, 1), (2, 0), (4, 2), (5, 3), (6, 4), (3, 6), (1, 5),
         (7, 7)],  # *--*
        [(0, 0), (2, 1), (4, 3), (5, 2), (6, 7), (3, 5), (1, 6),
         (7, 4)],  # -**-
        [(0, 1), (2, 0), (4, 3), (5, 2), (6, 7), (3, 5), (1, 6),
         (7, 4)],  # ***-
        [(0, 0), (2, 1), (4, 3), (5, 2), (6, 4), (3, 6), (1, 5),
         (7, 7)],  # -*-*
        [(0, 1), (2, 0), (4, 3), (5, 2), (6, 4), (3, 6), (1, 5),
         (7, 7)],  # **-*
        [(0, 0), (2, 1), (4, 3), (5, 2), (6, 7), (3, 6), (1, 5),
         (7, 4)],  # -***
        [(0, 1), (2, 0), (4, 3), (5, 2), (6, 7), (3, 6), (1, 5),
         (7, 4)],  # ****
        [(0, 0), (2, 1), (4, 2), (5, 3), (6, 7), (3, 6), (1, 5),
         (7, 4)],  # --**
        [(0, 1), (2, 0), (4, 2), (5, 3), (6, 7), (3, 6), (1, 5),
         (7, 4)],  # *-**
    ]
    # fmt: on
    ref = [sorted(r) for r in ref]

    # cost:
    # [[ 0.000  0.000  83.505  83.505  53.406  3.378  3.378  53.406]
    # [ 3.398  3.398  53.169  53.169  29.828  0.000  0.000  29.828]
    # [ 0.000  0.000  83.293  83.293  53.237  3.336  3.336  53.237]
    # [ 3.359  3.359  53.323  53.323  29.944  0.000  0.000  29.944]
    # [ 83.559  83.559  0.000  0.000  3.372  53.380  53.380  3.372]
    # [ 83.297  83.297  0.000  0.000  3.320  53.171  53.171  3.320]
    # [ 53.240  53.240  3.379  3.379  0.000  29.830  29.830  0.000]
    # [ 53.468  53.468  3.322  3.322  0.000  30.001  30.001  0.000]]
    # ptsCR [(0, 0), (2, 1), (4, 2), (5, 3), (6, 4), (3, 5), (1, 6), (7, 7)]

    #    ans = uno(edges, verbose=2)
    #    _check('Example 4a (internal match)', ans, ref, verbose=2)

    ans = uno(edges, verbose=2, match=match)
    _check("Example 4b (provided match)", ans, ref, verbose=2)
예제 #3
0
def test_example3(alg=1):

    # fmt: off
    match = [(1, 2), (3, 4), (5, 6), (7, 8)]
    edges = [(1, 2), (1, 4), (1, 6), (3, 4), (3, 6), (3, 8), (5, 6), (5, 8),
             (5, 2), (7, 8), (7, 2), (7, 4)]

    ref = [[(1, 2), (3, 6), (5, 8), (7, 4)], [(1, 2), (3, 4), (5, 6), (7, 8)],
           [(1, 2), (3, 8), (5, 6), (7, 4)], [(1, 4), (3, 6), (5, 2), (7, 8)],
           [(1, 4), (3, 6), (5, 8), (7, 2)], [(1, 4), (3, 8), (5, 6), (7, 2)],
           [(1, 6), (3, 4), (5, 2), (7, 8)], [(1, 6), (3, 4), (5, 8), (7, 2)],
           [(1, 6), (3, 8), (5, 2), (7, 4)]]
    # fmt: on

    ans = uno(edges, verbose=2)
    _check("Example 3a (internal match)", ans, ref)

    ans = uno(edges, verbose=2, match=match)
    _check("Example 3b (provided match)", ans, ref, verbose=2)