Remove a section of the web
This commit is contained in:
22
graphgif.scm
22
graphgif.scm
@@ -113,6 +113,28 @@
|
||||
(reverse lst)
|
||||
(loop (1+ i) (cons (make-node i) lst)))))
|
||||
|
||||
(define-public (remove-rect graph w x1 y1 x2 y2)
|
||||
;; Assumption is that is a graph generated by generate-web
|
||||
;; and that it has not been re-indexed
|
||||
;; x1 < x2, y1 < y2
|
||||
(define edges-to-remove
|
||||
(unfold (lambda (s) (> s (xy->idx x2 y2 w)))
|
||||
identity
|
||||
(lambda (s) (if (>= (idx->x s w) x2)
|
||||
(xy->idx x1 (1+ (idx->y s w)) w)
|
||||
(1+ s)))
|
||||
(xy->idx x1 y1 w)))
|
||||
(filter-map
|
||||
(lambda (idx/node)
|
||||
(if (memq (car idx/node) edges-to-remove)
|
||||
#f
|
||||
(cons (car idx/node)
|
||||
(set-node-edges (cdr idx/node)
|
||||
(remove
|
||||
(lambda (edge) (memq edge edges-to-remove))
|
||||
(node-edges (cdr idx/node)))))))
|
||||
graph))
|
||||
|
||||
;;;;;;;;;;;;
|
||||
;; Output ;;
|
||||
;;;;;;;;;;;;
|
||||
|
||||
Reference in New Issue
Block a user