def to_drawing(g, d=None, edges=[]):
    """
    draws Graph to a `Drawing`
    :param g: :class:`Graph`
    :param d: existing :class:`Drawing` to draw onto, or None to create a new Drawing
    :param edges: iterable of edges (with data) that will be added, in the same order. By default all edges are drawn
    :return: :class:`Drawing`

    Graph edges with an 'entity' property
    """
    from . import drawing, geom
    if d is None:
        d = drawing.Drawing()
    if not edges:
        edges = g.edges(data=True)
    for edge in edges:
        u, v, data = edge[0], edge[1], edge[-1]
        try:
            e = data['entity']
        except KeyError:
            u = g.pos(u)
            v = g.pos(v)
            e = geom.Segment2(u, v)
        d.append(e)
    return d
