def to_networkx(G):
	import networkx
	
	if type(G) == Graph:
		Gdest = networkx.Graph()
		
		# copy node objects and data
		for nobj,ndata in G.nodes_iter(data=True):
			if ndata is None:
				Gdest.add_node(nobj)
			else:
				Gdest.add_node(nobj,data=ndata)
		
		# copy edge objects and data
		for u,v,edata in G.edges_iter(data=True):
			if edata is None:
				Gdest.add_edge(u,v)
			else:
				Gdest.add_edge(u,v,data=edata)
				
		return Gdest
		
	elif type(G) == DiGraph:
		Gdest = networkx.DiGraph()
		
		# copy node objects and data
		for nobj,ndata in G.nodes_iter(data=True):
			if ndata is None:
				Gdest.add_node(nobj)
			else:
				Gdest.add_node(nobj,data=ndata)
		
		# copy edge objects and data
		for u,v,edata in G.edges_iter(data=True):
			if edata is None:
				Gdest.add_edge(u,v)
			else:
				Gdest.add_edge(u,v,data=edata)
				
		return Gdest
	else:
		raise ZenException, 'Cannot convert objects of type %s to NetworkX graph objects' % str(type(G))
	
# def to_wrapped_networkx(G):
# 	"""
# 	This function accepts a Zen graph object and returns an object which has the networkx interface.
# 	Note that this object will wrap the graph object passed in, so any changes made to the networkx
# 	object will also be reflected in the underlying graph.  The object returned maintains no state,
# 	so changes can be made to the underlying Zen graph without affecting the validity of the 
# 	wrapper.
# 	"""
# 	import networkx
# 	
# 	if type(G) == DiGraph:
# 		return DiGraphNXWrapper(G)
# 	else:
# 		raise Exception, 'Unable to convert graph object type %s' % str(type(G))
Convert a Zen graph object into a NetworkX graph object.
dataset/ETHPy150Open networkdynamics/zenlib/src/zen/nx.py/to_networkx