Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sumith1896/b7b1fe4ccb628d3e9196551987a2fc0f to your computer and use it in GitHub Desktop.
Save Sumith1896/b7b1fe4ccb628d3e9196551987a2fc0f to your computer and use it in GitHub Desktop.
(remove-child!
(lambda (parent child)
(if (enum-set-contains?
(apply enum-set-union
(map (curry vertex-parents graph)
(vertex-children graph child)))
parent)
(void)
(begin
(enum-set-remove! (vector-ref mb parent) child)
(enum-set-remove! (vector-ref mb child) parent)))
(for-enum-set ([other-parent (vertex-parents graph child)])
(unless (equal? parent other-parent)
(define others-child (vertex-children graph other-parent))
(define others-parent (vertex-parents graph other-parent))
(define others-childs-parents ((apply enum-set-union
(map (curry vertex-parents graph)
(vertex-children graph other-parent)))))
(if (enum-set-contains? (enum-set-union others-parent others-child
others-childs-parents) parent)
(void)
(begin
(enum-set-remove! (vector-ref mb parent) other-parent)
(enum-set-remove! (vector-ref mb other-parent) parent)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment