Separating levels of abstraction is the theme here. You are given an object graph and are asked to "invent" a corresponding class graph. The object graph happens to describe a class graph for class graph. So you have to jugle three levels of abstraction. Cd_graph = < first > Adj < rest > Adj_list_ . Adj = < vertex > Vertex < ns > Neighbors . Neighbors : Construct | Alternat . Construct = < c_ns > Any_vertex_list_ . Alternat = < first > Vertex < second > Vertex . Any_vertex_ : Labeled_vertex | Syntax_vertex . Nany_vertex_list = Any_Vertex_ Any_vertex_list_. Any_vertex_list_ : Nany_vertex_list | Empty. Empty = . Vertex = Ident. Labeled_vertex = Ident Vertex. Syntax_vertex = char. Adj_list_ : Empty_cd_graph | Cd_graph. Empty_cd_graph = .