# HG changeset patch # User Steve Losh # Date 1541273855 14400 # Node ID 8cf220c55f134e63a3c27e560750095ce58e3abb # Parent 10d265927e33c5aaf73bc9a08cbd376916a810b9 Make copy-digraph actually copy the data diff -r 10d265927e33 -r 8cf220c55f13 cl-digraph.asd --- a/cl-digraph.asd Sat Nov 03 15:30:06 2018 -0400 +++ b/cl-digraph.asd Sat Nov 03 15:37:35 2018 -0400 @@ -4,7 +4,7 @@ :homepage "https://sjl.bitbucket.io/cl-digraph/" :license "MIT/X11" - :version "1.2.0" + :version "1.2.1" :depends-on () diff -r 10d265927e33 -r 8cf220c55f13 docs/05-changelog.markdown --- a/docs/05-changelog.markdown Sat Nov 03 15:30:06 2018 -0400 +++ b/docs/05-changelog.markdown Sat Nov 03 15:37:35 2018 -0400 @@ -5,6 +5,11 @@ [TOC] +v1.2.1 +------ + +Fixed a bug in `copy-digraph`. + v1.2.0 ------ diff -r 10d265927e33 -r 8cf220c55f13 src/directed-graph.lisp --- a/src/directed-graph.lisp Sat Nov 03 15:30:06 2018 -0400 +++ b/src/directed-graph.lisp Sat Nov 03 15:37:35 2018 -0400 @@ -285,7 +285,7 @@ (let ((copy (make-digraph :test (digraph-test digraph) :hash-function (digraph-hash-function digraph) :initial-vertices (vertices digraph)))) - (do-edges (p s digraph) (insert-edge digraph p s)) + (do-edges (p s digraph) (insert-edge copy p s)) copy)) diff -r 10d265927e33 -r 8cf220c55f13 test/tests.lisp --- a/test/tests.lisp Sat Nov 03 15:30:06 2018 -0400 +++ b/test/tests.lisp Sat Nov 03 15:37:35 2018 -0400 @@ -33,6 +33,23 @@ (is (same () (edges g))) (is (not (emptyp g))))) +(define-test copy-digraph + (let ((g (make-digraph :initial-vertices '(a b c))) + (h nil)) + (insert-edge g 'a 'b) + (is (same '(a b c) (vertices g))) + (is (same '((a . b)) (edges g))) + (setf h (copy-digraph g)) + (is (same '(a b c) (vertices h))) + (is (same '((a . b)) (edges h))) + (remove-edge h 'a 'b) + (remove-vertex h 'c) + (is (same '(a b) (vertices h))) + (is (same '() (edges h))) + ;; make sure the original didn't change + (is (same '(a b c) (vertices g))) + (is (same '((a . b)) (edges g))))) + (define-test roots-and-leafs (let ((g (make-digraph)))