(load "Graph2.lisp") (in-package :cl-graph) (defun dfs (graph root visited) (if (null visited) (setq visited (cons 'dummy nil))) (push root (cdr visited)) (iterate-neighbors root #'(lambda (x) (unless (find x visited) (dfs graph x visited)))) (reverse (cdr visited))) (defun ford-fulkerson (source sink) (let* ((cur-flow 0) (graph (generate-graph)) ;; maybe make that global variable, so that it can be changed from other functions (augm-path (find-augmented-path (find-residual-graph graph) source sink))) (while augm-path (send-flow graph augm-path (weight (find-min-edge-in-path))) (incf cur-flow (weight (find-min-edge-in-path))) (setf augm-path (find-augmented-path (find-residual-graph graph) source sink))))) (defun find-residual-graph (graph) ) (defun find-augmented-path (graph source sink) ;;remember to return nil if i didn't find any augmented path, otherwise the algorithm will not work ) (defun send-flow (graph path flow) ) (defun find-min-edge-in-path (path) (let ((cur-weight (weight (car path))) (cur-edge (car path))) (dotimes (i (length path)) (if (< (weight (elt path i)) cur-weight) (setf cur-weight (weight (elt path i)) cur-edge (elt path i)))) ;;probably don't need to keep cur-edge cur-weight))