MyGit

stuartsierra/dependency

Fork: 30 Star: 225 (更新于 2024-12-11 06:32:05)

license: 暂无

Language: Clojure .

A data structure for representing dependency graphs in Clojure

GitHub网址

Dependency

A data structure for representing dependency graphs in Clojure.

This library provides a basic implementation of a directed acyclic graph (DAG) data structure, represented as a pair of maps. It is immutable and persistent.

Nodes in the graph may be any type which supports Clojure's equality semantics such as keywords, symbols, or strings.

I originally developed this library to support namespace dependency tracking in tools.namespace, where it is still included under the name clojure.tools.namespace.dependency.

I am releasing this library independently so that other projects can use it without adding a dependency on all of tools.namespace.

Releases and Dependency Information

This library is released on Clojars. Latest stable release is 1.0.0.

Leiningen dependency information:

[com.stuartsierra/dependency "1.0.0"]

deps.edn dependency information:

com.stuartsierra/dependency {:mvn/version "1.0.0"}

Version Compatibility

Versions 0.2.0 and higher are .cljc supporting both Clojure (versions 1.7.0 and higher) and ClojureScript with Conditional Read.

Version 0.1.1 remains compatible with versions of Clojure before 1.7.0.

Usage

(require '[com.stuartsierra.dependency :as dep])

Create a new dependency graph:

(def g1 (-> (dep/graph)
            (dep/depend :b :a)   ; "B depends on A"
            (dep/depend :c :b)   ; "C depends on B"
            (dep/depend :c :a)   ; "C depends on A"
            (dep/depend :d :c))) ; "D depends on C"

This creates a structure like the following:

     :a
    / |
  :b  |
    \ |
     :c
      |
     :d

Ask questions of the graph:

(dep/transitive-dependencies g1 :d)
;;=> #{:a :c :b}

(dep/depends? g1 :d :b)
;;=> true

Get a topological sort:

(dep/topo-sort g1)
;;=> (:a :b :c :d)

Refer to the docstrings for more API documentation. Refer to the tests for more examples.

Development and Contributing

This library is a repackaging of clojure.tools.namespace.dependency. All changes must go through tools.namespace and the Clojure contributing process.

Change Log

  • Release 1.0.0 on 07-Mar-2020
    • Set Clojure dependency scope to 'provided'
  • Release 0.2.0 on 18-Sept-2015
    • Convert to .cljc for ClojureScript support
    • Apply enhancements and fixes up to tools.namespace version 0.3.0-alpha1
  • Release 0.1.1 on 03-Jun-2013
    • A node may not depend on itself; fixes #1
  • Release 0.1.0 on 07-Apr-2013

Copyright and License

Copyright (c) Stuart Sierra, 2012-2015. All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.

最近版本更新:(数据更新于 2024-09-12 10:39:51)

stuartsierra/dependency同语言 Clojure最近更新仓库

2024-12-16 22:29:36 logseq/logseq

2024-11-04 23:45:19 penpot/penpot

2024-10-03 02:18:04 metabase/metabase

2023-02-20 20:09:25 adamtornhill/code-maat

2021-12-07 04:58:58 tonsky/FiraCode

2018-04-17 22:19:15 emanjavacas/cosycat