[cl-graph-devel] copying a graph
Gary King
gwking at metabang.com
Thu Mar 23 13:51:20 UTC 2006
P.S., I might also want to look at copy-template in moptilities. Here
is the documentation (sorry about wrapping)
;;;
------------------------------------------------------------------------
---
;;; copy-template
;;; suppose you have an object
;;; ? (defclass foo ()
;;; ((test :accessor test :initform #'equal :initarg :test))) =>
;;; #<STANDARD-CLASS FOO>
;;;
;;; ? (setf *foo* (make-instance 'foo :test #'eql))
;;;
;;; ? (test *foo*) => #'eql
;;;
;;; Now you want to make another instance of foo that has the same
test as *foo*.
;;;
;;; ? (setf *new-foo* (make-instance (type-of foo)))
;;;
;;; ? (test *new-foo*) => #'equal
;;;
;;; Wait, we wanted *new-foo* to have slot test to be #'eql. This
seems trival
;;; for simple objects, but consider this from make-filtered-graph
;;;
;;; (make-graph (type-of old-graph)
;;; :vertex-test (vertex-test old-graph)
;;; :vertex-key (vertex-key old-graph)
;;; :edge-test (edge-test old-graph)
;;; :edge-key (edge-key old-graph)
;;; :default-edge-type (default-edge-type old-graph)
;;; :default-edge-class (default-edge-class old-graph)
;;; :directed-edge-class (directed-edge-class old-graph)
;;; :undirected-edge-class (undirected-edge-class old-
graph))))
;;; Yuck!
;;;
;;; So we offer copy-template as a reasonable, though not perfect,
solution
;;;
------------------------------------------------------------------------
---
On Mar 21, 2006, at 12:57 PM, Alexis Gallagher wrote:
> Hi,
>
> Is there a way to make a (deep) copy of a graph? I've looked in the
> library and I can't find anything like copy-graph, copy-edge, or
> copy-vertex.
>
> I'm wondering about this, because I discovered I couldn't build a
> transformed version of a graph just by creating a new graph object and
> then adding edges from the old one. But if I can't do that, then
> what is
> the best way to write functions that transform a graph
> nondestructively?
>
> If I wanted to write such a function, is there anything I should know
> about which information needs to be preserved so that the duplicate
> object functions correctly with the other tools in the system?
>
> Cheers,
> alexis
>
> p.s. FYI, cl-graph adsf-installs fine on SBCL 0.9.7 on OS X. But I
> still
> haven't got it working on CMUCL 19a / Debian stable. Has anyone else?
> _______________________________________________
> cl-graph-devel mailing list
> cl-graph-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/cl-graph-devel
--
Gary Warren King
metabang.com
http://www.metabang.com/
More information about the cl-graph-devel
mailing list