def is_stranded(G, q):
    """Returns True iff `q` is stranded in `G`.

    A vertex `q` in `G` is :dfn:`stranded` if there is no
    edge starting at `q` or if there is no edge ending at `q`.

    Parameters
    ----------
    G : graph
    q : vertex in `G`

    Examples
    --------
    >>> G = nx.MultiDiGraph()
    >>> G.add_edge(1, 2)
    >>> sd.is_stranded(G, 1)
    True
    >>> G.add_edge(1, 1)
    >>> sd.is_stranded(G, 1)
    False

    See Also
    --------
    :func:`is_essential`

    """
    return not (G.out_edges(q) and G.in_edges(q))