;;;
;;;
;;; Graph demonstration
;;;
;;;
;;
;; Matcher definitions
;;
(define $graph
(lambda [$a]
(set (edge a))))
(define $edge
(lambda [$a]
(algebraic-data-matcher
{})))
;;
;; Sample data
;;
(define $graph-data1
{
})
(define $graph-data2
{
})
;;
;; Demonstration code
;;
;; find all nodes who have an edge from 's' but not have an edge to 's'
(test (let {[$s 1]}
(match-all graph-data1 (graph integer)
[
!
_>>
x])))
;; find all nodes in two paths from 's'
(test (let {[$s 1]}
(match-all graph-data1 (graph integer)
[
_>>
x])))
;; enumerate first 5 paths from 's' to 'e'
(test (take 5 (let {[$s 1] [$e 2]}
(match-all graph-data2 (graph integer)
[
(loop $i [4 $n]
...>
_>)>
x]))))
;; find all cliques whose size is 'n'
(test (let {[$n 3]}
(match-all graph-data2 (graph integer)
[
(loop $i [3 n]
(loop $j [2 (- i 1)]
...>
...)
_>
_)>
x])))