Mirror 'root' functionality for leaf nodes
[cl-graph.git] / dev / graph.lisp
index 6df7ec3..1f50e3a 100644 (file)
@@ -644,11 +644,19 @@ something is putting something on the vertexes plist's
   (collect-elements (graph-vertexes graph) :filter #'rootp))
 
 
+(defmethod graph-leafs ((graph basic-graph))
+  (collect-elements (graph-vertexes graph) :filter #'leafp))
+
+
 (defmethod rootp ((vertex basic-vertex))
   ;;?? this is inefficient in the same way that (zerop (length <list>)) is...
   (zerop (target-edge-count vertex)))
 
 
+(defmethod leafp ((vertex basic-vertex))
+  (zerop (source-edge-count vertex)))
+
+
 (defmethod find-vertex-if ((graph basic-graph) fn &key key)
   (iterate-vertexes graph
                     (lambda (v)