>>> from networkx import *
>>> import networkx.utils
>>> import os,tempfile

>>> data="""Creator me
... graph [
...  comment "This is a sample graph"
...  directed 1
...  IsPlanar 1
...  pos  [ x 0 y 1 ]
...  node [
...    id 1
...    label "Node 1"
...    pos [ x 1 y 1 ] 
...  ]
...  node [
...     id 2
...     pos [ x 1 y 2 ] 
...     label "Node 2" 
...     ]
...   node [
...     id 3
...     label "Node 3"
...     pos [ x 1 y 3 ] 
...   ]
...   edge [
...     source 1
...     target 2
...     label "Edge from node 1 to node 2"
...     color [ line 'blue'   thickness 3 ] 
...   ]
...   edge [
...     source 2
...     target 3
...     label "Edge from node 2 to node 3"
...   ]
...   edge [
...     source 3
...     target 1 label
...     "Edge from node 3 to node 1"
...   ]
... ]
... """

>>> G=parse_gml(data)

>>> print sorted(G.nodes())
['Node 1', 'Node 2', 'Node 3']

>>> print [e for e in sorted(G.edges(data=True))]
[('Node 1', 'Node 2', {'color': {'line': 'blue', 'thickness': 3}, 'label': 'Edge from node 1 to node 2'}), ('Node 2', 'Node 3', {'label': 'Edge from node 2 to node 3'}), ('Node 3', 'Node 1', {'label': 'Edge from node 3 to node 1'})]


>>> (fd,fname)=tempfile.mkstemp()
>>> fh=open(fname,'w')
>>> fh.write(data)
>>> fh.close()
>>> Gin=read_gml(fname)
>>> sorted(G.nodes())==sorted(Gin.nodes())
True
>>> sorted(G.edges())==sorted(Gin.edges())
True
>>> os.close(fd)
>>> os.unlink(fname)

>>> (fd,fname)=tempfile.mkstemp()

>>> write_gml(G,fname)
>>> H=read_gml(fname)
>>> sorted(H.nodes())==sorted(G.nodes())
True
>>> sorted(H.edges())==sorted(G.edges())
True
