6.001, Spring Semester, 2005--Pro ject 3 (define (graph? graph) boolean (and (pair? graph)(eq? 'graph (car graph)))) (define (graph-elements graph Graph - list<Graph-Element> (if (not (graph? graph)) (error object not a graph: "graph) (cdr graph))) (define (graph-r oot graph) oh - Node null (let ((elements ( graph-elements graph))) (if (null? elements) (gr aph-element->node (car elements))))) In the above implement ation, we will arbitrarily consider the first graph-element to hold the"root for the graph. The procedure graph-root ret urns t he root node Given these abstractions, we can construct the graph in Figure 2(with node a as the root )using (define test (make-graph (1 (make-graph-element ]a '(b i m)'(some words)) (make-graph-element 'b '(c d e h),(more words)) (make-graph-element 'c 1('(at c node some words ) (make-graph-element e ,(f g) make-gr ap g0,0) (make-graph-element ' h 10)10) make-graph-element ]i '(j k 1)'(more words yet)) (make-graph-element j1(10) Note that several of t he no des have no children . and t hat several have no contents We would like to have some accessors to get connect ivity and content s information out of the graph Find the specified node in the graph (define (find-graph-element graph node) Graph, Node - Graph-Element Inull (define(find el cond((null? elements)o) ((eq? (graph-element->node (car elements)) node) (car elements)) (else (find (cdr elements))))) (find(graph-elements graph))) We are often more interested in the node children or node content, rat her than the graph-element The find-node-children and find-node-contents accessor pro cedures can be implemented follows ( "" & ( )( ' & % & ( *+ $ * & , ( - & + ,2 & 1 1 ,* % + >% += + + /0 + +! + # % + ! 2 +% ,%%& 1 % + + ' 81+ % + 9 %) ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' . ' ' ' ' ' ' ' ' ' ' '+ ' " '+ ' ' ' ' ' ' ' ' + %2 + % +2 +& + %2 +2 %! 3 1 4 +2 % %%% 2* % + +! 3 >% > > += +& 2 + 8!! + %*, + >% + 9) / & , ( ' )( & 3 % + + %& + + + +=! + %% % , % 1%)