def _prepare_graph(g, g_colors, q_cls, q_arg, adjust_graph):
g = _test_graph(g)<EOL>if adjust_graph:<EOL><INDENT>pos = nx.get_node_attributes(g, '<STR_LIT>')<EOL>ans = nx.to_dict_of_dicts(g)<EOL>g = adjacency2graph(ans, adjust=<NUM_LIT:2>, is_directed=g.is_directed())<EOL>g = QueueNetworkDiGraph(g)<EOL>if len(pos) > <NUM_LIT:0>:<EOL><INDENT>g.set_pos(pos)<EOL><DEDENT><DEDENT>g.new_vertex_property('<STR_LIT>')<EOL>g.new_vertex_property('<STR_LIT>')<EOL>g.new_vertex_property('<STR_LIT>')<EOL>g.new_vertex_property('<STR_LIT>')<EOL>g.new_edge_property('<STR_LIT>')<EOL>g.new_edge_property('<STR_LIT>')<EOL>g.new_edge_property('<STR_LIT>')<EOL>g.new_edge_property('<STR_LIT>')<EOL>queues = _set_queues(g, q_cls, q_arg, '<STR_LIT>' in g.vertex_properties())<EOL>if '<STR_LIT>' not in g.vertex_properties():<EOL><INDENT>g.set_pos()<EOL><DEDENT>for k, e in enumerate(g.edges()):<EOL><INDENT>g.set_ep(e, '<STR_LIT>', <NUM_LIT>)<EOL>g.set_ep(e, '<STR_LIT>', <NUM_LIT:8>)<EOL>if e[<NUM_LIT:0>] == e[<NUM_LIT:1>]:<EOL><INDENT>g.set_ep(e, '<STR_LIT>', queues[k].colors['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>g.set_ep(e, '<STR_LIT>', queues[k].colors['<STR_LIT>'])<EOL><DEDENT><DEDENT>for v in g.nodes():<EOL><INDENT>g.set_vp(v, '<STR_LIT>', <NUM_LIT:1>)<EOL>g.set_vp(v, '<STR_LIT>', <NUM_LIT:8>)<EOL>e = (v, v)<EOL>if g.is_edge(e):<EOL><INDENT>g.set_vp(v, '<STR_LIT>', queues[g.edge_index[e]]._current_color(<NUM_LIT:2>))<EOL>g.set_vp(v, '<STR_LIT>', queues[g.edge_index[e]]._current_color())<EOL><DEDENT>else:<EOL><INDENT>g.set_vp(v, '<STR_LIT>', g_colors['<STR_LIT>'])<EOL>g.set_vp(v, '<STR_LIT>', g_colors['<STR_LIT>'])<EOL><DEDENT><DEDENT>return g, queues<EOL>
Prepares a graph for use in :class:`.QueueNetwork`.

    This function is called by ``__init__`` in the
    :class:`.QueueNetwork` class. It creates the :class:`.QueueServer`
    instances that sit on the edges, and sets various edge and node
    properties that are used when drawing the graph.

    Parameters
    ----------
    g : :any:`networkx.DiGraph`, :class:`numpy.ndarray`, dict, \
        ``None``,  etc.
        Any object that networkx can turn into a
        :any:`DiGraph<networkx.DiGraph>`
    g_colors : dict
        A dictionary of colors. The specific keys used are
        ``vertex_color`` and ``vertex_fill_color`` for vertices that
        do not have any loops. Set :class:`.QueueNetwork` for the
        default values passed.
    q_cls : dict
        A dictionary where the keys are integers that represent an edge
        type, and the values are :class:`.QueueServer` classes.
    q_args : dict
        A dictionary where the keys are integers that represent an edge
        type, and the values are the arguments that are used when
        creating an instance of that :class:`.QueueServer` class.
    adjust_graph : bool
        Specifies whether the graph will be adjusted using
        :func:`.adjacency2graph`.

    Returns
    -------
    g : :class:`.QueueNetworkDiGraph`
    queues : list
        A list of :class:`QueueServers<.QueueServer>` where
        ``queues[k]`` is the ``QueueServer`` that sets on the edge with
        edge index ``k``.

    Notes
    -----
    The graph ``g`` should have the ``edge_type`` edge property map.
    If it does not then an ``edge_type`` edge property is
    created and set to 1.

    The following properties are set by each queue: ``vertex_color``,
    ``vertex_fill_color``, ``vertex_fill_color``, ``edge_color``.
    See :class:`.QueueServer` for more on setting these values.

    The following properties are assigned as a properties to the graph;
    their default values for each edge or vertex is shown:

        * ``vertex_pen_width``: ``1``,
        * ``vertex_size``: ``8``,
        * ``edge_control_points``: ``[]``
        * ``edge_marker_size``: ``8``
        * ``edge_pen_width``: ``1.25``

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