Idiomatic construction and inspection of graphs backed by JGraphT.
Vertices are arbitrary Clojure values (keywords, strings, numbers, maps).
Graphs are JGraphT's native mutable objects: constructors and mutators return
the same graph for threading, but they mutate in place (this is a performance
wrapper, not a persistent data structure). Algorithms live in cljgrapht.algo
and return plain Clojure data.
Idiomatic construction and inspection of graphs backed by JGraphT. Vertices are arbitrary Clojure values (keywords, strings, numbers, maps). Graphs are JGraphT's native mutable objects: constructors and mutators return the same graph for threading, but they mutate in place (this is a performance wrapper, not a persistent data structure). Algorithms live in `cljgrapht.algo` and return plain Clojure data.
(add-edge g u v)(add-edge g u v w)Add an edge u -> v (optionally with weight w) to g, adding the vertices
if absent. Returns g.
Add an edge `u -> v` (optionally with weight `w`) to `g`, adding the vertices if absent. Returns `g`.
(add-vertex g v)Add vertex v to g, returning g.
Add vertex `v` to `g`, returning `g`.
(digraph)(digraph edges)A directed graph. Optional edges is a seq of [u v] pairs.
A directed graph. Optional `edges` is a seq of [u v] pairs.
(edges g)A seq of edges in g: [u v] pairs, or [u v w] triples when g is weighted.
A seq of edges in `g`: [u v] pairs, or [u v w] triples when `g` is weighted.
(graph)(graph edges)An undirected graph. Optional edges is a seq of [u v] pairs.
An undirected graph. Optional `edges` is a seq of [u v] pairs.
(neighbors g v)Vertices adjacent to v in g (direction-agnostic).
Vertices adjacent to `v` in `g` (direction-agnostic).
(predecessors g v)Vertices with an edge into v in g.
Vertices with an edge into `v` in `g`.
(successors g v)Vertices reachable from v by an outgoing edge in g.
Vertices reachable from `v` by an outgoing edge in `g`.
(weight g u v)The weight of the edge u -> v in g.
The weight of the edge `u -> v` in `g`.
(weighted-digraph)(weighted-digraph edges)A directed weighted graph. Optional edges is a seq of [u v w] triples.
A directed weighted graph. Optional `edges` is a seq of [u v w] triples.
(weighted-graph)(weighted-graph edges)An undirected weighted graph. Optional edges is a seq of [u v w] triples.
An undirected weighted graph. Optional `edges` is a seq of [u v w] triples.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |