'Return an undirected representation of the digraph.
Parameters
reciprocal : bool (optional)
If True only keep edges that appear in both directions
in the original digraph.
Returns
G : Graph
An undirected graph with the same name and nodes and
with edge (u, v, data) if either (u, v, data) or (v, u, data)
is in the digraph.  If both edges exist in digraph and
their edge data is different, only one edge is created
with an arbitrary choice of which edge data to use.
You must check and correct for this manually if desired.
Notes
If edges in both directions (u, v) and (v, u) exist in the
graph, attributes for the new undirected edge will be a combination of
the attributes of the directed edges.  The edge data is updated
in the (arbitrary) order that the edges are encountered.  For
more customized control of the edge attributes use add_edge().
This returns a "deepcopy" of the edge, node, and
graph attributes which attempts to completely copy
all of the data and references.
This is in contrast to the similar G=DiGraph(D) which returns a
shallow copy of the data.
See the Python copy module for more information on shallow
and deep copies, http://docs.python.org/library/copy.html.
Warning: If you have subclassed DiGraph to use dict-like objects
in the data structure, those changes do not transfer to the
Graph created by this method.'

def to_undirected(self, reciprocal=False):

    H = Graph()
    H.name = self.name
    H.add_nodes_from(self)
    if (reciprocal is True):
        H.add_edges_from(((u, v, deepcopy(d)) for (u, nbrs) in self.adjacency() for (v, d) in nbrs.items() if (v in self._pred[u])))
    else:
        H.add_edges_from(((u, v, deepcopy(d)) for (u, nbrs) in self.adjacency() for (v, d) in nbrs.items()))
    H.graph = deepcopy(self.graph)
    H._node = deepcopy(self._node)
    return H
