From: Gary King Date: Thu, 27 Apr 2006 13:35:21 +0000 (-0400) Subject: Improved efficiency of edge-count for graphs in general (from (length (graph-edges... X-Git-Url: http://repo.macrolet.net/gitweb/?p=cl-graph.git;a=commitdiff_plain;h=5282d117ab0e8b7080bca9683e270f0d2a8f4d5c Improved efficiency of edge-count for graphs in general (from (length (graph-edges ...)) to (count-using ...)) and for graph-containers in particular (just use size). darcs-hash:20060427133521-3cc5d-07b4bcedb22efc1e6badfcc16c3b9c9e76d44fa1.gz --- diff --git a/dev/graph-container.lisp b/dev/graph-container.lisp index afafdda..0865b2f 100644 --- a/dev/graph-container.lisp +++ b/dev/graph-container.lisp @@ -208,7 +208,6 @@ DISCUSSION ;;; --------------------------------------------------------------------------- - (defmethod find-edge ((graph graph-container) (edge graph-container-edge) &optional error-if-not-found?) (find-edge-between-vertexes @@ -312,7 +311,8 @@ DISCUSSION (values nil)) +;;; --------------------------------------------------------------------------- + +(defmethod edge-count ((graph graph-container)) + (size (graph-edges graph))) -;;; *************************************************************************** -;;; * End of File * -;;; *************************************************************************** \ No newline at end of file diff --git a/dev/graph.lisp b/dev/graph.lisp index a8f782b..b2c1cf3 100644 --- a/dev/graph.lisp +++ b/dev/graph.lisp @@ -1065,7 +1065,7 @@ nil gathers the entire closure(s)." ;;; --------------------------------------------------------------------------- (defmethod edge-count ((graph basic-graph)) - (length (edges graph))) + (count-using #'iterate-edges nil graph)) ;;; ---------------------------------------------------------------------------