Functions for working with graphs.
Functions for working with graphs.
(add-edge g edge)
Adds an edge to the graph.
Adds an edge to the graph.
(add-vertex g x)
Adds a vertex to the graph.
Adds a vertex to the graph.
(articulation-points g)
Returns a set of vertices where the removal of that vertex will partition the graph.
Returns a set of vertices where the removal of that vertex will partition the graph.
(bfs-vertices v adjacent)
Performs a breadth-first traversal through a graph implicitly defined by a function (adjacent v) -> [v1, v2, ...] (or any Iterable of vertices). Starts with a single vertex v, and returns an Iterable of vertices.
Performs a breadth-first traversal through a graph implicitly defined by a function (adjacent v) -> [v1, v2, ...] (or any Iterable of vertices). Starts with a single vertex v, and returns an Iterable of vertices.
(bfs-vertices-from-any vs adjacent)
Like bfs-vertices, but takes an Iterable of starting vertices.
Like bfs-vertices, but takes an Iterable of starting vertices.
(biconnected-components g)
Returns a set of sets of vertices where each vertex can reach every other vertex within the set, even if a single vertex is removed.
Returns a set of sets of vertices where each vertex can reach every other vertex within the set, even if a single vertex is removed.
(bottom g)
Unclear what this does. Might be broken?
Unclear what this does. Might be broken?
(connected-components g)
Returns a set of sets of vertices where each vertex can reach every other vertex within the set.
Returns a set of sets of vertices where each vertex can reach every other vertex within the set.
(cycles g)
Returns a list of lists of all cyclical paths through the graph.
Returns a list of lists of all cyclical paths through the graph.
(digraph)
(digraph hash-fn equals-fn)
Constructs a new directed graph, optionally with custom hash and equality semantics (hash vertex) and (equals? vertex1 vertex2).
Constructs a new directed graph, optionally with custom hash and equality semantics (hash vertex) and (equals? vertex1 vertex2).
(directed-acyclic-graph)
(directed-acyclic-graph hash-fn equals-fn)
Constructs a new directed acyclic graph, optionally with custom hash and equality semantics (hash vertex) and (equals? vertex1 vertex2).
Constructs a new directed acyclic graph, optionally with custom hash and equality semantics (hash vertex) and (equals? vertex1 vertex2).
(directed-edge from to)
(directed-edge from to value)
Constructs a new directed edge with an optional value.
Constructs a new directed edge with an optional value.
(edge g from to)
The edge value between from
and to
. Throws if edge doesn't exist.
The edge value between `from` and `to`. Throws if edge doesn't exist.
(edge-directed? edge)
Is an edge from a directed graph?
Is an edge from a directed graph?
(edge-from edge)
The source vertex of an edge
The source vertex of an edge
(edge-to edge)
The destination vertex of an edge.
The destination vertex of an edge.
(edge-value edge)
The value associated with an edge.
The value associated with an edge.
(edges g)
An interable over every edge in the graph.
An interable over every edge in the graph.
(graph)
(graph hash-fn equals-fn)
Constructs a new Graph, optionally with custom hash and equality semantics (hash vertex) and (equals? vertex1 vertex2).
Constructs a new Graph, optionally with custom hash and equality semantics (hash vertex) and (equals? vertex1 vertex2).
(in g v)
The set of all vertices that lead directly into this vertex.
The set of all vertices that lead directly into this vertex.
(index-of g v)
Returns the index of the given vertex, if present, or nil.
Returns the index of the given vertex, if present, or nil.
(link g from to)
(link g from to e)
(link g from to e merge)
Returns graph with vertex from
linked to to
, optionally via edge e
,
optionally with e
merged into an existing edge via (merge extant-edge e)
.
Returns graph with vertex `from` linked to `to`, optionally via edge `e`, optionally with `e` merged into an existing edge via `(merge extant-edge e)`.
(map-edges g f)
Transforms every edge's value by applying (f edge) -> value'
Transforms every edge's value by applying (f edge) -> value'
(merge a b merge-fn)
Merges two graphs together using a function (merge-fn edge-value1 edge-value2).
Merges two graphs together using a function (merge-fn edge-value1 edge-value2).
(out g v)
The set of all vertices this vertex directly leads to.
The set of all vertices this vertex directly leads to.
(remove g x)
Removes a vertex from the graph.
Removes a vertex from the graph.
(select g vertices)
A graph containing only the specified vertices and the edges between them.
A graph containing only the specified vertices and the edges between them.
(shortest-path g start accept? cost)
Finds the shortest path, if one exists, from starting vertex to any vertex where (accept? v) is truthy, using (cost edge) -> double to determine the cost of each edge. Nil if no path exists.
Finds the shortest path, if one exists, from starting vertex to any vertex where (accept? v) is truthy, using (cost edge) -> double to determine the cost of each edge. Nil if no path exists.
(shortest-path-from-any g starts accept? cost)
Finds the shortest path, if one exists, from any one of an iterable of starting vertices to any vertex where (accept? v) is truthy, using (cost edge) -> double to determine the cost of each edge. Nil if no path exists.
Finds the shortest path, if one exists, from any one of an iterable of starting vertices to any vertex where (accept? v) is truthy, using (cost edge) -> double to determine the cost of each edge. Nil if no path exists.
(strongly-connected-components g)
(strongly-connected-components g include-singletons?)
Sets of sets of vertices where each vertex can reach every other vertex in that set. include-singletons? indicates whether single-vertex sets are allowed.
Sets of sets of vertices where each vertex can reach every other vertex in that set. include-singletons? indicates whether single-vertex sets are allowed.
(strongly-connected-subgraphs g)
(strongly-connected-subgraphs g include-singletons?)
A list of graphs of strongly connected components in g. include-singletons? indicates whether single-vertex sets are allowed.
A list of graphs of strongly connected components in g. include-singletons? indicates whether single-vertex sets are allowed.
(top g)
This appears to be the vertices which have no in edges.
This appears to be the vertices which have no in edges.
(transpose g)
Transposes a graph, flipping the direction of each edge.
Transposes a graph, flipping the direction of each edge.
(undirected-edge from to)
(undirected-edge from to value)
Constructs a new undirected edge with an optional value.
Constructs a new undirected edge with an optional value.
(unlink g from to)
Removes the link between from
and to
.
Removes the link between `from` and `to`.
(vertex-equality g)
Returns the vertex equality function of a graph
Returns the vertex equality function of a graph
(vertex-hash g)
Returns the vertex hash function of a graph.
Returns the vertex hash function of a graph.
(vertices g)
The set of all vertices in the graph
The set of all vertices in the graph
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close