Make copy-digraph actually copy the data
author |
Steve Losh <steve@stevelosh.com> |
date |
Sat, 03 Nov 2018 15:37:35 -0400 |
parents |
10d265927e33
|
children |
4a86a78b3de6
|
branches/tags |
v1.2.1 |
files |
cl-digraph.asd docs/05-changelog.markdown src/directed-graph.lisp test/tests.lisp |
Changes
--- 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 ()
--- 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
------
--- 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))
--- 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)))