Directed graph operations and specifications.
Directed graph operations and specifications.
(adj-edges graph v)
Returns the set of all edges that v is adjacent to, meaning all edges that originate from v.
Returns the set of all edges that v is adjacent to, meaning all edges that originate from v.
(adj? graph x y)
Returns true if x is adjacent to y in the given graph, where adjacent is defined as the existence of an edge originating from x and terminating at y.
Returns true if x is adjacent to y in the given graph, where adjacent is defined as the existence of an edge originating from x and terminating at y.
(cyclic? graph)
Returns true if the given graph contains a cycle, false otherwise.
Returns true if the given graph contains a cycle, false otherwise.
(indegree graph v)
Returns the indegree of the given node, where indegree is defined as the number of edges that terminate at a given node. Returns nil if the given node is not present in the graph.
Returns the indegree of the given node, where indegree is defined as the number of edges that terminate at a given node. Returns nil if the given node is not present in the graph.
(internal? graph v)
Returns true if the given node is internal, where internal is defined as having a non-zero indegree and outdegree.
Returns true if the given node is internal, where internal is defined as having a non-zero indegree and outdegree.
(make-digraph node-set & edges)
Constructs a new directed graph.
Constructs a new directed graph.
(outdegree graph v)
Returns the outdegree of the given node, where outdegree is defined as the number of edges that originate from a given node. Returns nil if the given node is not present in the graph.
Returns the outdegree of the given node, where outdegree is defined as the number of edges that originate from a given node. Returns nil if the given node is not present in the graph.
(sink? graph v)
Returns true if the given node is a sink, where sink is defined as having an outdegree count of zero, and a non-zero indegree count.
Returns true if the given node is a sink, where sink is defined as having an outdegree count of zero, and a non-zero indegree count.
(source? graph v)
Returns true if the given node is a source, where source is defined as having an indegree count of zero, and a non-zero outdegree count.
Returns true if the given node is a source, where source is defined as having an indegree count of zero, and a non-zero outdegree count.
(stranded? graph v)
Returns true if the given node is stranded, meaning that both its indegree and outdegree are zero.
Returns true if the given node is stranded, meaning that both its indegree and outdegree are zero.
(topological-sort {:keys [nodes] :as graph})
Returns a vector of the given graph's nodes in topological order, or nil if the graph can not be sorted (e.g. it contains a cycle). Uses Kahn's algorithm to compute the sort.
Returns a vector of the given graph's nodes in topological order, or nil if the graph can not be sorted (e.g. it contains a cycle). Uses Kahn's algorithm to compute the sort.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close