def set_types_random(g, proportions=None, loop_proportions=None, seed=None,<EOL>**kwargs):
g = _test_graph(g)<EOL>if isinstance(seed, numbers.Integral):<EOL><INDENT>np.random.seed(seed)<EOL><DEDENT>if proportions is None:<EOL><INDENT>proportions = {k: <NUM_LIT:1.> / <NUM_LIT:3> for k in range(<NUM_LIT:1>, <NUM_LIT:4>)}<EOL><DEDENT>if loop_proportions is None:<EOL><INDENT>loop_proportions = {k: <NUM_LIT:1.> / <NUM_LIT:4> for k in range(<NUM_LIT:4>)}<EOL><DEDENT>edges = [e for e in g.edges() if e[<NUM_LIT:0>] != e[<NUM_LIT:1>]]<EOL>loops = [e for e in g.edges() if e[<NUM_LIT:0>] == e[<NUM_LIT:1>]]<EOL>props = list(proportions.values())<EOL>lprops = list(loop_proportions.values())<EOL>if not np.isclose(sum(props), <NUM_LIT:1.0>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if not np.isclose(sum(lprops), <NUM_LIT:1.0>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>eTypes = {}<EOL>types = list(proportions.keys())<EOL>values = np.random.choice(types, size=len(edges), replace=True, p=props)<EOL>for k, e in enumerate(edges):<EOL><INDENT>eTypes[e] = values[k]<EOL><DEDENT>types = list(loop_proportions.keys())<EOL>values = np.random.choice(types, size=len(loops), replace=True, p=lprops)<EOL>for k, e in enumerate(loops):<EOL><INDENT>eTypes[e] = values[k]<EOL><DEDENT>g.new_edge_property('<STR_LIT>')<EOL>for e in g.edges():<EOL><INDENT>g.set_ep(e, '<STR_LIT>', eTypes[e])<EOL><DEDENT>return g<EOL>
Randomly sets ``edge_type`` (edge type) properties of the graph.

    This function randomly assigns each edge a type. The probability of
    an edge being a specific type is proscribed in the
    ``proportions``, ``loop_proportions`` variables.

    Parameters
    ----------
    g : :any:`networkx.DiGraph`, :class:`numpy.ndarray`, dict, etc.
        Any object that :any:`DiGraph<networkx.DiGraph>` accepts.
    proportions : dict (optional, default: ``{k: 0.25 for k in range(1, 4)}``)
        A dictionary of edge types and proportions, where the keys are
        the types and the values are the proportion of non-loop edges
        that are expected to be of that type. The values can must sum
        to one.
    loop_proportions : dict (optional, default: ``{k: 0.25 for k in range(4)}``)
        A dictionary of edge types and proportions, where the keys are
        the types and the values are the proportion of loop edges
        that are expected to be of that type. The values can must sum
        to one.
    seed : int (optional)
        An integer used to initialize numpy's psuedorandom number
        generator.
    **kwargs :
        Unused.

    Returns
    -------
    :class:`.QueueNetworkDiGraph`
        Returns the a graph with an ``edge_type`` edge property.

    Raises
    ------
    TypeError
        Raised when the parameter ``g`` is not of a type that can be
        made into a :any:`networkx.DiGraph`.

    ValueError
        Raises a :exc:`~ValueError` if the ``pType`` values do not sum
        to one.

    Notes
    -----
    If ``pTypes`` is not explicitly specified in the arguments, then it
    defaults to four types in the graph (types 0, 1, 2, and 3). It sets
    non-loop edges to be either 1, 2, or 3 33\% chance, and loops are
    types 0, 1, 2, 3 with 25\% chance.