 (define G1 '( (A (B 6) (C 5))
              (B (D 8))
              (C (A 1) (D 1))
              (D (C 7) (E 5) (W 3))
              (E (A 11) (F 10))
              (F)
              (W) )
  )

(define (getNodeInfo node Graph)
  (if (null? Graph)
      '()
      (if (eqv? node (caar Graph))
          (cdar Graph)
          (getNodeInfo node (cdr Graph))
       )
  )
 )

(define (isNeighbour? node nodeList)
  (if (null? nodeList)
      #f
      (if (eqv?  node (caar nodeList) )
          #t
          (isNeighbour? node (cdr nodeList))
      )
    )
)

(define (inList element list)
  (if (null? list)
      #f
      (if (eqv? element (car list))
          #t
          (inList element (cdr list))
       )
   )
 )

(define (isPath? startNode endNode Graph)
  (define (innerIsPath startNode endNode Graph visited)
    (define (neighboursLoop nodeList)
      (if (null? nodeList)
          #f
          (if (and (not (inList (caar NodeList) visited)) (innerIsPath (caar NodeList) endNode Graph (cons startNode visited)) )
              #t
              (neighboursLoop (cdr nodeList))
              )
          )
     )
    (define (isPathSub nodeInfo)
      (if (isNeighbour? endNode nodeInfo)
          #t
          (if (null? nodeInfo)
              #f
              (neighboursLoop nodeInfo)
              )
          )
      )
    (isPathSub (getNodeInfo startNode Graph))
  )
  (define (isNode node Graph)
    (if (null? Graph)
        #f
        (if (eqv? (caar Graph) node)
            #t
            (isNode node (cdr Graph))
        )
    )
  )
  (if (or (not (isNode startNode Graph)) (not (isNode endNode Graph) ) )
      #f
      (if (eqv? startNode endNode)
          #t
          (innerIsPath startNode endNode Graph '())
       )
   )
 )

(isPath? 'A 'B G1)