bump version
[cl-graph.git] / dev / graph-container.lisp
index 544a0c4..91fde47 100644 (file)
@@ -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)))))
 
 ;;; ---------------------------------------------------------------------------