def construct_k_colored_graph(k, n, p):
    '\n    Constructs a k colored graph of n nodes in which a pair\n    of nodes shares an edge with probability 0 <= p <= 1.\n\n    Note: this code is for demonstrative purposes only; the\n    solution for such a problem will not necessarily exist,\n    in which case the concretization process will throw\n    an exception.\n    '
    with coopy.scope():
        nodes = [Node() for i in range(n)]
        for i in range((n - 1)):
            for j in range((i + 1), n):
                a = nodes[i]
                b = nodes[j]
                if (random.uniform(0, 1) < p):
                    a.direct_edge_towards(b)
                    b.direct_edge_towards(a)
        for node in nodes:
            coopy.any([(node.color == i) for i in range(k)]).require()
            node.has_valid_connections.require()
        coopy.concretize()
        return nodes
Constructs a k colored graph of n nodes in which a pair
of nodes shares an edge with probability 0 <= p <= 1.

Note: this code is for demonstrative purposes only; the
solution for such a problem will not necessarily exist,
in which case the concretization process will throw
an exception.
def construct_k_colored_graph(k, n, p):
    '\n    Constructs a k colored graph of n nodes in which a pair\n    of nodes shares an edge with probability 0 <= p <= 1.\n\n    Note: this code is for demonstrative purposes only; the\n    solution for such a problem will not necessarily exist,\n    in which case the concretization process will throw\n    an exception.\n    '
    with coopy.scope():
        nodes = [Node() for i in range(n)]
        for i in range((n - 1)):
            for j in range((i + 1), n):
                a = nodes[i]
                b = nodes[j]
                if (random.uniform(0, 1) < p):
                    a.direct_edge_towards(b)
                    b.direct_edge_towards(a)
        for node in nodes:
            coopy.any([(node.color == i) for i in range(k)]).require()
            node.has_valid_connections.require()
        coopy.concretize()
        return nodes