code: func newMarshalGraph(name string, g *Graph) *marshalGraph {
  	mg := &marshalGraph{
  		Type:  "Graph",
  		Name:  name,
  		Attrs: make(map[string]string),
  	}
  
  	for _, v := range g.Vertices() {
  		id := marshalVertexID(v)
  		if sg, ok := marshalSubgrapher(v); ok {
  			smg := newMarshalGraph(VertexName(v), sg)
  			smg.ID = id
  			mg.Subgraphs = append(mg.Subgraphs, smg)
  		}
  
  		mv := newMarshalVertex(v)
  		mg.Vertices = append(mg.Vertices, mv)
  	}
  
  	sort.Sort(vertices(mg.Vertices))
  
  	for _, e := range g.Edges() {
  		mg.Edges = append(mg.Edges, newMarshalEdge(e))
  	}
  
  	sort.Sort(edges(mg.Edges))
  
  	for _, c := range (&AcyclicGraph{*g}).Cycles() {
  		var cycle []*marshalVertex
  		for _, v := range c {
  			mv := newMarshalVertex(v)
  			cycle = append(cycle, mv)
  		}
  		mg.Cycles = append(mg.Cycles, cycle)
  	}
  
  	return mg
  }
docs: // build a marshalGraph structure from a *Graph