Beispiel #1
0
 def _test(*args, io=print, path=None, **kwargs):
     """
     the decorated function to be returned
     """
     io('\n~%s~\nGraph:\n%s' % (algorithm.__name__, args[0]))
     cr, d = algorithm(*args, **kwargs)
     circle_plot(args[0], d, algorithm.__name__, path=path)
     io('\nResults:\n%s %s\n' % (cr, d))
     return cr, d
Beispiel #2
0
def randomizedTest(G, N, io=print, path=None):
    """
    runs randomized MRCN algorithm N times, returning the result of the
    maximal round; prints results, and saves resultant drawing to a .png
    picture file at desired path
    """
    io('randomized:\nGraph:\n%s' % G)
    max_cr, max_d = randomized(G)
    for i in range(N):
        curr, curr_d = randomized(G)
        if curr > max_cr:
            max_cr, max_d = curr, curr_d[:]
    circle_plot(G, max_d, randomized.__name__, path=path)
    io('\nResults:\n%s %s' % (max_cr, max_d))
    return max_cr, max_d