(require-library eggdoc) (import eggdoc) (define doc `((eggdoc:begin (name "digraph") (description "Directed graph in adjacency list format.") (author (url "http://chicken.wiki.br/users/ivan-raikov" "Ivan Raikov")) (history (version "1.11" "Ported to Chicken 4") (version "1.10" "Now using matchable extension") (version "1.9" "Added procedures pred-list and succ-list") (version "1.8" "Added procedure node-info-set!") (version "1.7" "Build script updated for better cross-platform compatibility") (version "1.6" "Test infrastructure changed to use testbase") (version "1.5" "Bug fixes in set-out-edges! and set-in-edges! [thanks to Andreas Scholta]") (version "1.4" "License upgrade to GPL v3") (version "1.3" "Updated the roots procedure to match the documentation") (version "1.2" "Minor changes to the setup script") (version "1.1" "Added support for chicken-setup -test") (version "1.0" "Initial release")) (requires (url "dyn-vector.html" "dyn-vector") (url "syntax-case.html" "syntax-case") (url "matchable.html" "matchable")) (usage "(require-extension digraph)") (download "digraph.egg") (documentation (p "The digraph library is an implementation of a directed " "graph, where the edges are stored as adjacency lists " "indexed by node number.") (p "The library defines a digraph \"object\" -- a procedure that " "takes a method name as a symbol, and returns the procedure that " "implements the respective operation.") (subsection "Directed graph procedures" (p "The digraph object is created by procedure " (tt "make-digraph") ", which is the only user-visible procedure defined in this egg: ") (procedure "make-digraph:: NAME INFO [NODE-LIST [SUCC-LIST [PRED-LIST]]] -> SELECTOR" (p "where " (tt "NAME") " is the graph name (string or symbol), " (tt "INFO") " is an optional metadata object of an arbitrary type " "or " (tt "#f") "; " (tt ("NODE-LIST")) " is an optional list of nodes to be inserted in the graph; " "each element of the list must be of the form " (tt "(N INFO)") " where " (tt "N") " is a unique node number (integer), and " (tt "INFO") " is an optional metadata object describing the node. " "Similarly, " (tt "SUCC-LIST") " and " (tt "PRED-LIST") " can be used " " to define the graph edges upon graph creation. If supplied, these arguments " "must be lists in which every element is of the form " (tt "(I J INFO)") ", where " (tt "I") " and " (tt "J") " are node numbers, " "and " (tt "INFO") " is an optional metadata object.")) (p "The returned selector procedure can take one of the following arguments: " (symbol-table (describe "'name" "returns the graph name (string or symbol)") (describe "'info" "returns the graph metadata (arbitrary type)") (describe "'new-id!" ("returns a procedure with no arguments, " "which returns the lowest available node number")) (describe "'add-node!" ("returns a procedure " (tt "LAMBDA N INFO") " which inserts in the graph node with number " (tt "N") " and metadata " (tt "INFO") "; if the node already " "exists in the graph, it will be overwritten with the " "new metadata")) (describe "'add-edge!" ("returns a procedure " (tt "LAMBDA EDGE") " which inserts in the graph the specifed edge; " "the edge is given by a list of the form " (tt "(I J INFO)") ", where " (tt "I") " and " (tt "J") " are source and destination nodes, respectively, and " (tt "INFO") " is edge metadata of arbitrary type")) (describe "'remove-node!" ("returns a procedure " (tt "LAMBDA N") " which removes node " (tt "N") " and all its edges from the graph")) (describe "'nodes" ("returns a procedure with no arguments, " "which returns a list with the nodes of the graph " "and their metadata")) (describe "'edges" ("returns a procedure with no arguments, " "which returns a list with the edges of the graph " "and their metadata")) (describe "'roots" ("returns a procedure with no arguments, " "which returns a list with all nodes in the graph " "that do not have an predecessor")) (describe "'order" ("returns a procedure with no arguments, " "which returns the number of nodes in the graph")) (describe "'size" ("returns a procedure with no arguments, " "which returns the number of edges in the graph")) (describe "'capacity" ("returns a procedure with no arguments, " "which returns the size of the underlying dynamic vector")) (describe "'succ" ("returns a procedure " (tt "LAMBDA N") " which returns a list with the successor nodes of node " (tt "N"))) (describe "'pred" ("returns a procedure " (tt "LAMBDA N") " which returns a list with the predecessor nodes of node " (tt "N"))) (describe "'succ-list" ("returns a procedure with no arguments " " which returns a list containing the successor nodes for each node.")) (describe "'pred-list" ("returns a procedure with no arguments " " which returns a list containing the predecessor nodes for each node.")) (describe "'out-edges" ("returns a procedure " (tt "LAMBDA N") " which returns a list with the outgoing edges of node " (tt "N"))) (describe "'in-edges" ("returns a procedure " (tt "LAMBDA N") " which returns a list with the incoming edges of node " (tt "N"))) (describe "'has-edge" ("returns a procedure " (tt "LAMBDA I J") " which returns true if edge " (tt "I -> J") " exists in the graph " "and false otherwise")) (describe "'has-node" ("returns a procedure " (tt "LAMBDA N") " which returns true if node " (tt "N") " exists in the graph " "and false otherwise")) (describe "'node-info" ("returns a procedure " (tt "LAMBDA N") " which returns the metadata for node " (tt "N"))) (describe "'node-info-set!" ("returns a procedure " (tt "LAMBDA N V") " which sets the metadata for node " (tt "N"))) (describe "'foreach-node" ("returns an iterator procedure " (tt "LAMBDA F") " which iterates over the nodes in the graph " "by invoking function " (tt "F") " on the node number and metadata " "of each node")) (describe "'foreach-edge" ("returns an iterator procedure " (tt "LAMBDA F") " which iterates over the edges in the graph " "by invoking function " (tt "F") " on each edge")) (describe "'debug" ("returns a list with the internal representation of the graph")))))) (examples (pre #<~A" ni nj))))) (else (error "invalid edge " e)))) used-by) (print ((g 'nodes))) (print ((g 'edges))) ((g 'remove-node!) 0) (print ((g 'nodes))) (print ((g 'edges))) EOF ) (license "Copyright Ivan Raikov and the Okinawa Institute of Science and Technology This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A full copy of the GPL license can be found at ."))))) (if (eggdoc->html doc) (void))