{"id":17504670,"url":"https://github.com/iraikov/chicken-digraph","last_synced_at":"2026-01-06T01:38:43.059Z","repository":{"id":148366461,"uuid":"49463486","full_name":"iraikov/chicken-digraph","owner":"iraikov","description":"Scheme implementation of a directed graph in adjacency list format","archived":false,"fork":false,"pushed_at":"2018-12-09T14:33:11.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T16:28:01.044Z","etag":null,"topics":["chicken-scheme","chicken-scheme-eggs","digraph","graph","scheme-language"],"latest_commit_sha":null,"homepage":null,"language":"Scheme","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iraikov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-12T00:24:40.000Z","updated_at":"2020-06-15T17:19:29.000Z","dependencies_parsed_at":"2023-05-13T18:30:38.460Z","dependency_job_id":null,"html_url":"https://github.com/iraikov/chicken-digraph","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"c1e6f29ae443f0fbcba2c1602e8513297a723177"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iraikov%2Fchicken-digraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iraikov%2Fchicken-digraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iraikov%2Fchicken-digraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iraikov%2Fchicken-digraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iraikov","download_url":"https://codeload.github.com/iraikov/chicken-digraph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245525765,"owners_count":20629832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chicken-scheme","chicken-scheme-eggs","digraph","graph","scheme-language"],"created_at":"2024-10-20T01:19:09.722Z","updated_at":"2026-01-06T01:38:38.012Z","avatar_url":"https://github.com/iraikov.png","language":"Scheme","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chicken-digraph\n\nScheme implementation of a directed graph in adjacency list format\n\nThe `digraph` library is an implementation of a directed graph, where\nthe edges are stored as adjacency lists indexed by node number.\n\n## Directed graph procedures\n\nThe digraph object is created by procedure `make-digraph`:\n\n\n\u003cprocedure\u003emake-digraph:: NAME INFO [NODE-LIST [SUCC-LIST [PRED-LIST]]] -\u003e SELECTOR\u003c/procedure\u003e\n\nwhere:\n\n- `NAME` is the graph name (string or symbol)\n- `INFO` is an optional metadata object of an arbitrary type or {{#f}}\n- `NODE-LIST` is an optional list of nodes to be inserted in the graph; each element of the list must be of the form {{(N INFO)}} where {{N}} is a unique node number (integer), and {{INFO}} is an optional metadata object describing the node. \n- `SUCC-LIST` and {{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 {{(I J INFO)}}, where {{I}} and {{J}} are node numbers, and {{INFO}} is an optional metadata object.\n\n\nThe returned yasos object supports the following operations:\n\n- 'name` : returns the graph name (string or symbol)\n- 'info` : returns the graph metadata (arbitrary type)\n- 'new-id!` : returns the lowest available node number\n- 'add-node!` : procedure `LAMBDA N INFO` which inserts in the graph node with number `N` and metadata `INFO`- if the node already exists in the graph, it will be overwritten with the new metadata\n- 'add-edge!` : procedure `LAMBDA EDGE` which inserts in the graph the specifed edge- the edge is given by a list of the form `(I J INFO)`, where `I` and `J` are source and destination nodes, respectively, and `INFO` is edge metadata of arbitrary type\n- 'remove-node!` : procedure `LAMBDA N` which removes node `N` and all its edges from the graph\n- 'nodes` : returns a list with the nodes of the graph and their metadata\n- 'edges` : returns a list with the edges of the graph and their metadata\n- 'roots` : returns a list with all nodes in the graph that do not have an predecessor\n- 'terminals` : returns a list with all nodes in the graph that do not have a successor\n- 'order` : returns the number of nodes in the graph\n- 'size` : returns the number of edges in the graph\n- 'capacity` : returns the size of the underlying dynamic vector\n- 'succ` : procedure `LAMBDA N` which returns a list with the successor nodes of node `N`\n- 'pred` : procedure `LAMBDA N` which returns a list with the predecessor nodes of node `N`\n- 'succ-list` : returns a list containing the successor nodes for each node.\n- 'pred-list` : returns a list containing the predecessor nodes for each node.\n- 'out-edges` : procedure `LAMBDA N` which returns a list with the outgoing edges of node `N`\n- 'in-edges` : procedure `LAMBDA N` which returns a list with the incoming edges of node `N`\n- 'has-edge` : procedure `LAMBDA I J` which returns true if edge `I -\u003e J` exists in the graph and false otherwise\n- 'has-node` : procedure `LAMBDA N` which returns true if node `N` exists in the graph and false otherwise\n- 'node-info` : procedure `LAMBDA N` which returns the metadata for node `N`\n- 'node-info-set!` : procedure `LAMBDA N V` which sets the metadata for node `N`\n- 'fold-node` :  procedure `LAMBDA F RES` which iterates over the nodes in the graph by invoking function `F` on the node number, metadata of each node, and accumulator variable `RES`\n- 'fold-edge` : procedure `LAMBDA F RES` which iterates over the edges in the graph by invoking function `F` on each edge and accumulator variable `RES`\n- 'foreach-node` : procedure `LAMBDA F` which iterates over the nodes in the graph by invoking function `F` on the node number and metadata of each node\n- 'foreach-edge` : procedure `LAMBDA F` which iterates over the edges in the graph by invoking function `F` on each edge\n\n\n## Examples\n\n```scheme\n\n ;; example adapted from graph example in the Boost library documentation\n (import srfi-1 digraph matchable)\n    \n (define g (make-digraph 'depgraph \"dependency graph\"))\n    \n (define used-by\n    (list \n      (cons 'dax_h 'foo_cpp) (cons 'dax_h 'bar_cpp) (cons 'dax_h 'yow_h)\n      (cons 'yow_h 'bar_cpp) (cons 'yow_h 'zag_cpp) (cons 'boz_h 'bar_cpp)\n      (cons 'boz_h 'zig_cpp) (cons 'boz_h 'zag_cpp) (cons 'zow_h 'foo_cpp)\n      (cons 'foo_cpp 'foo_o) (cons 'foo_o 'libfoobar_a) \n      (cons 'bar_cpp 'bar_o) (cons 'bar_o 'libfoobar_a) \n      (cons 'libfoobar_a 'libzigzag_a) (cons 'zig_cpp 'zig_o) \n      (cons 'zig_o 'libzigzag_a) (cons 'zag_cpp 'zag_o) \n      (cons 'zag_o 'libzigzag_a) (cons 'libzigzag_a 'killerapp)))\n \n \n (define node-list (delete-duplicates \n \t\t   (concatenate (list (map car used-by) (map cdr used-by)))))\n \n (define node-ids (list-tabulate (length node-list) values))\n  \n (for-each (lambda (i n) (add-node! g i n)) node-ids node-list)\n (define node-map (zip node-list node-ids))\n \n (for-each (lambda (e) \n \t    (match e ((ni . nj) (let ((i (car (alist-ref ni node-map)))\n \t\t\t\t      (j (car (alist-ref nj node-map))))\n \t\t\t\t  (add-edge! g (list i j (format \"~A-\u003e~A\" ni nj)))))\n \t\t   (else (error \"invalid edge \" e))))\n \t  used-by)\n (print (nodes g))\n (print (edges g))\n \n (remove-node! g 0)\n (print (nodes g))\n (print (edges g))\n\n```\n\n\n## License\n\n```\n Copyright 2007-2018 Ivan Raikov.\n \n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or (at\n your option) any later version.\n \n This program is distributed in the hope that it will be useful, but\n WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n General Public License for more details.\n \n A full copy of the GPL license can be found at\n \u003chttp://www.gnu.org/licenses/\u003e.\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firaikov%2Fchicken-digraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firaikov%2Fchicken-digraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firaikov%2Fchicken-digraph/lists"}