X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=dev%2Fgraph-container.lisp;h=91fde47f25b8d4e791c846664ca613a03a2bd36d;hb=64273bb2bd2c48860e33dc1945c49eb867a32d19;hp=544a0c49d56d9ec9c26a1f5417010c1a1dab194d;hpb=529a8f60bae410ef4c1f90a2f3f4c1a44a66df5b;p=cl-graph.git diff --git a/dev/graph-container.lisp b/dev/graph-container.lisp index 544a0c4..91fde47 100644 --- a/dev/graph-container.lisp +++ b/dev/graph-container.lisp @@ -211,10 +211,9 @@ DISCUSSION &key error-if-not-found?) (bind ((v1 (find-vertex graph value-1 error-if-not-found?)) (v2 (find-vertex graph value-2 error-if-not-found?))) - (aif (and v1 v2 (find-edge-between-vertexes-if graph v1 v2 fn)) - it - (when error-if-not-found? - (error 'graph-edge-not-found-error :vertex-1 v1 :vertex-2 v2))))) + (or (and v1 v2 (find-edge-between-vertexes-if graph v1 v2 fn)) + (when error-if-not-found? + (error 'graph-edge-not-found-error :vertex-1 v1 :vertex-2 v2))))) ;;; --------------------------------------------------------------------------- @@ -237,6 +236,14 @@ DISCUSSION :test #'eq))) edge) +(defmethod delete-all-edges ((graph graph-container)) + (iterate-vertexes + graph + (lambda (vertex) + (empty! (vertex-edges vertex)))) + (empty! (vertex-pair->edge graph)) + graph) + ;;; --------------------------------------------------------------------------- (defmethod empty! :after ((graph graph-container)) @@ -261,7 +268,7 @@ DISCUSSION (iterate-elements (vertex-edges vertex) (lambda (edge) (when (or (undirected-edge-p edge) - (eq vertex (target-vertex edge))) + (eq vertex (source-vertex edge))) (funcall fn edge))))) ;;; --------------------------------------------------------------------------- @@ -270,7 +277,7 @@ DISCUSSION (iterate-elements (vertex-edges vertex) (lambda (edge) (when (or (undirected-edge-p edge) - (eq vertex (source-vertex edge))) + (eq vertex (target-vertex edge))) (funcall fn edge))))) ;;; ---------------------------------------------------------------------------