Liking cljdoc? Tell your friends :D

loom.alg-generic

Graph algorithms for use on any type of graph

Graph algorithms for use on any type of graph
raw docstring

ancestor?clj/s

(ancestor? ancestry childer parenter)

Finds if the 'parenter node is an ancestor of 'childer node for the given 'ancestry cache.

Finds if the 'parenter node is an ancestor of 'childer node for the given
'ancestry cache.
sourceraw docstring

ancestorsclj/s

(ancestors ancestry child)

Returns all of the ancestors of 'child node.

Returns all of the ancestors of 'child node.
sourceraw docstring

Ancestryclj/s

source

ancestry-addclj/s

(ancestry-add ancestry node & parents)

Adds a 'node and its 'parents associations to the 'ancestry cache.

Adds a 'node and its 'parents associations to the 'ancestry cache.
sourceraw docstring

ancestry-contains?clj/s

(ancestry-contains? ancestry node)

Finds if a 'node is contained in the 'ancestry cache.

Finds if a 'node is contained in the 'ancestry cache.
sourceraw docstring

ancestry-newclj/s

(ancestry-new)

Create a new, empty Ancestry cache.

Create a new, empty Ancestry cache.
sourceraw docstring

ancestry-nodesclj/s

(ancestry-nodes ancestry)

Returns all of the nodes in an 'ancestry.

Returns all of the nodes in an 'ancestry.
sourceraw docstring

bf-pathclj/s

(bf-path successors start end & {:as opts})

Returns a path from start to end with the fewest hops (i.e. irrespective of edge weights), successors being a function that returns adjacent nodes

Returns a path from start to end with the fewest hops (i.e. irrespective
of edge weights), successors being a function that returns adjacent nodes
sourceraw docstring

bf-path-biclj/s≠

(bf-path-bi outgoing predecessors start end)
clj

Using a bidirectional breadth-first search, finds a path from start to end with the fewest hops (i.e. irrespective of edge weights), outgoing and predecessors being functions which return adjacent nodes. Can be much faster than a unidirectional search on certain types of graphs

Using a bidirectional breadth-first search, finds a path from start
to end with the fewest hops (i.e. irrespective of edge weights),
outgoing and predecessors being functions which return adjacent
nodes. Can be much faster than a unidirectional search on certain
types of graphs
source (clj)source (cljs)raw docstring

bf-paths-biclj/s

(bf-paths-bi successors predecessors start end)

Using a bidirectional breadth-first search, returns all shortest paths from start to end; predecessors is called on end and each preceding node, successors is called on start, etc.

Using a bidirectional breadth-first search, returns all shortest
paths from start to end; predecessors is called on end and each
preceding node, successors is called on start, etc.
sourceraw docstring

bf-spanclj/s

(bf-span successors start & {:keys [seen]})

Return a breadth-first spanning tree of the form {node [successors]}

Return a breadth-first spanning tree of the form {node
[successors]}
sourceraw docstring

bf-traverseclj/s

(bf-traverse successors start & {:keys [f when seen]})

Traverses a graph breadth-first from start, successors being a function that returns adjacent nodes. When :f is provided, returns a lazy seq of (f node predecessor-map depth) for each node traversed. Otherwise, returns a lazy seq of the nodes. When :when is provided, filters successors with (f neighbor predecessor depth).

Traverses a graph breadth-first from start, successors being a
function that returns adjacent nodes. When :f is provided, returns a
lazy seq of (f node predecessor-map depth) for each node traversed.
Otherwise, returns a lazy seq of the nodes. When :when is provided,
filters successors with (f neighbor predecessor depth).
sourceraw docstring

bits-per-longclj/s

source

bm-getclj/s

(bm-get bitmap idx)

Get boolean state of bit in 'bitmap at 'idx.

Get boolean state of bit in 'bitmap at 'idx.
sourceraw docstring

bm-get-indiciesclj/s

(bm-get-indicies bitmap)

Get the indicies of set bits in 'bitmap.

Get the indicies of set bits in 'bitmap.
sourceraw docstring

bm-longsclj/s

(bm-longs bits)

Returns the number of longs required to store bits count bits in a bitmap.

Returns the number of longs required to store bits count bits in a bitmap.
sourceraw docstring

bm-newclj/s

(bm-new)

Create new empty bitmap.

Create new empty bitmap.
sourceraw docstring

bm-orclj/s

(bm-or & bitmaps)

Logically OR 'bitmaps together.

Logically OR 'bitmaps together.
sourceraw docstring

bm-setclj/s

(bm-set bitmap idx)

Set boolean state of bit in 'bitmap at 'idx to true.

Set boolean state of bit in 'bitmap at 'idx to true.
sourceraw docstring

dijkstra-pathclj/s

(dijkstra-path successors dist start end)

Finds the shortest path from start to end, where successors and dist are functions called as (successors node) and (dist node1 node2)

Finds the shortest path from start to end, where successors and dist
are functions called as (successors node) and (dist node1 node2)
sourceraw docstring

dijkstra-path-distclj/s

(dijkstra-path-dist successors dist start end)

Finds the shortest path from start to end, where successors and dist are functions called as (successors node) and (dist node1 node2). Returns a vector: [path distance]

Finds the shortest path from start to end, where successors and dist
are functions called as (successors node) and (dist node1 node2).
Returns a vector: [path distance]
sourceraw docstring

dijkstra-spanclj/s

(dijkstra-span successors dist start)

Finds all shortest distances from start, where successors and dist are functions called as (successors node) and (dist node1 node2). Returns a map in the format {node {successor distance}}

Finds all shortest distances from start, where successors and dist
are functions called as (successors node) and (dist node1 node2).
Returns a map in the format {node {successor distance}}
sourceraw docstring

dijkstra-traverseclj/s

(dijkstra-traverse successors dist start)
(dijkstra-traverse successors dist start f)

Returns a lazy-seq of [current-node state] where state is a map in the format {node [distance predecessor]}. When f is provided, returns a lazy-seq of (f node state) for each node

Returns a lazy-seq of [current-node state] where state is a map in the
format {node [distance predecessor]}. When f is provided, returns
a lazy-seq of (f node state) for each node
sourceraw docstring

pathsclj/s

(paths preds path)

Returns a lazy seq of all non-looping path vectors starting with [<start-node>]

Returns a lazy seq of all non-looping path vectors starting with
[<start-node>]
sourceraw docstring

post-edge-traverseclj/s

(post-edge-traverse successors
                    start
                    &
                    {:keys [seen return-seen] :or {seen #{}}})

Traverses a graph depth-first postorder from start, successors being a function that returns direct successors for the node. Returns a seq of edges, each edge being a vector [source-node dest-node]. Note that for undirected graphs each edge will be returned twice, once for each direction.

Traverses a graph depth-first postorder from start, successors being
a function that returns direct successors for the node. Returns a
seq of edges, each edge being a vector [source-node dest-node].
Note that for undirected graphs each edge will be returned twice,
once for each direction.
sourceraw docstring

post-traverseclj/s

(post-traverse successors start & {:keys [seen return-seen] :or {seen #{}}})

Traverses a graph depth-first postorder from start, successors being a function that returns adjacent nodes. Returns a vector

Traverses a graph depth-first postorder from start, successors
being a function that returns adjacent nodes. Returns a vector
sourceraw docstring

pre-edge-traverseclj/s

(pre-edge-traverse successors start & {:keys [seen] :or {seen #{}}})

Traverses a graph depth-first preorder from start, successors being a function that returns direct successors for the node. Returns a lazy seq of edges, each edge being a vector [source-node dest-node]. Note that for undirected graphs each edge will be returned twice, once for each direction.

Traverses a graph depth-first preorder from start, successors being
a function that returns direct successors for the node. Returns a
lazy seq of edges, each edge being a vector [source-node dest-node].
Note that for undirected graphs each edge will be returned twice,
once for each direction.
sourceraw docstring

pre-spanclj/s

(pre-span successors start & {:keys [seen return-seen] :or {seen #{}}})

Returns a depth-first spanning tree of the form {node [successors]}

Returns a depth-first spanning tree of the form {node [successors]}
sourceraw docstring

pre-traverseclj/s

(pre-traverse successors start & {:keys [seen] :or {seen #{}}})

Traverses a graph depth-first preorder from start, successors being a function that returns direct successors for the node. Returns a lazy seq of nodes.

Traverses a graph depth-first preorder from start, successors being
a function that returns direct successors for the node. Returns a
lazy seq of nodes.
sourceraw docstring

preds->spanclj/s

(preds->span preds)

Converts a map of the form {node predecessor} to a spanning tree of the form {node [successors]}

Converts a map of the form {node predecessor} to a spanning tree of the
form {node [successors]}
sourceraw docstring

topsort-componentclj/s

(topsort-component successors start)
(topsort-component successors start seen explored)

Topological sort of a component of a (presumably) directed graph. Returns nil if the graph contains any cycles. See loom.alg/topsort for a complete topological sort

Topological sort of a component of a (presumably) directed graph.
Returns nil if the graph contains any cycles. See loom.alg/topsort
for a complete topological sort
sourceraw docstring

trace-pathclj/s

(trace-path preds node)

Using a map of nodes-to-preds, traces a node's family tree back to the source. Cycles are not accounted for.

Using a map of nodes-to-preds, traces a node's family tree back to the
source. Cycles are not accounted for.
sourceraw docstring

trace-pathsclj/s

(trace-paths preds start)

Given a function and a starting node, returns all possible paths back to source. Cycles are not accounted for.

Given a function and a starting node, returns all possible paths
back to source. Cycles are not accounted for.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close