示例#1
0
def setup_graphs(g_orig, forbidden):
    # g is a copy of g_orig; g_allowed contains only the allowed edges of g_orig
    g_pkl = cPickle_dumps(g_orig, cPickle_HIGHEST_PROTOCOL)
    g = cPickle_loads(g_pkl)
    g_allowed = cPickle_loads(g_pkl)
    adj = g_allowed.adj
    for u, v in forbidden:
        del adj[u][v]
        del adj[v][u]  # assumes no self loops
    return g_allowed, g
示例#2
0
def _setup_graphs(g_orig, eqs, forbidden, tears):
    # g is a copy of g_orig; g_allowed contains only the allowed edges of g_orig
    g_pkl = cPickle_dumps(g_orig, cPickle_HIGHEST_PROTOCOL)
    g = cPickle_loads(g_pkl)
    g_allowed = cPickle_loads(g_pkl)
    adj = g_allowed.adj
    for u, v in forbidden:
        del adj[u][v]
        del adj[v][u]  # assumes no self loops
    g_torn = cPickle_loads(g_pkl)
    g_torn.remove_nodes_from(tears)
    return g_allowed, g, g_torn
示例#3
0
def fast_copy(obj):
    pkl_str = cPickle_dumps(obj, cPickle_HIGHEST_PROTOCOL)
    return cPickle_loads(pkl_str)