code: def test_write_p2g(self):
      s = b"""foo
  3 2
  1
  1 
  2
  2 
  3
  
  """
      fh = io.BytesIO()
      G = nx.DiGraph()
      G.name = "foo"
      G.add_edges_from([(1, 2), (2, 3)])
      write_p2g(G, fh)
      fh.seek(0)
      r = fh.read()
      assert r == s
  
file_path: networkx/networkx/readwrite/tests/test_p2g.py
imports: import io
  import networkx
  from networkx.readwrite.p2g import read_p2g, write_p2g
  from networkx.utils import edges_equal
label_desc: Use image node_id 3 for calling the TestP2G obj's underlying member method code with example usage: obj.test_write_p2g() without return types