code: def encode(self, g, top=None, triples=False):
          
          if len(g.triples()) == 0:
              raise EncodeError('Cannot encode empty graph.')
          if triples:
              return self._encode_triple_conjunction(g, top=top)
          else:
              return self._encode_penman(g, top=top)
docs: Serialize the graph *g* from *top* to PENMAN notation.
  
          Args:
              g: the Graph object
              top: the node identifier for the top of the serialized
                  graph; if unset, the original top of *g* is used
              triples: if True, serialize as a conjunction of logical triples
          Returns:
              the PENMAN-serialized string of the Graph *g*
          Example:
  
              >>> codec = PENMANCodec()
              >>> codec.encode(Graph([('h', 'instance', 'hi')]))
              (h / hi)
              >>> codec.encode(Graph([('h', 'instance', 'hi')]),
              ...                      triples=True)
              instance(h, hi)