Defines protocols for graphs, digraphs, and weighted graphs. Also provides record implementations and constructors for simple graphs -- weighted, unweighted, directed, and undirected. The implementations are based on adjacency lists.
Defines protocols for graphs, digraphs, and weighted graphs. Also provides record implementations and constructors for simple graphs -- weighted, unweighted, directed, and undirected. The implementations are based on adjacency lists.
Weight used when none is given for edges in weighted graphs
Weight used when none is given for edges in weighted graphs
(add-cycle g & nodes)
Adds a cycle of edges connecting the given nodes in order
Adds a cycle of edges connecting the given nodes in order
(add-edges g & edges)
Adds edges to graph g. For unweighted graphs, edges take the form [n1 n2]. For weighted graphs, edges take the form [n1 n2 weight] or [n1 n2], the latter defaulting to a weight of 1
Adds edges to graph g. For unweighted graphs, edges take the form [n1 n2]. For weighted graphs, edges take the form [n1 n2 weight] or [n1 n2], the latter defaulting to a weight of 1
(add-nodes g & nodes)
Adds nodes to graph g. Nodes can be any type of object
Adds nodes to graph g. Nodes can be any type of object
(add-path g & nodes)
Adds a path of edges connecting the given nodes in order
Adds a path of edges connecting the given nodes in order
(build-graph g & inits)
Builds up a graph (i.e. adds edges and nodes) from any combination of other graphs, adjacency maps, edges, or nodes.
Builds up a graph (i.e. adds edges and nodes) from any combination of other graphs, adjacency maps, edges, or nodes.
(in-degree g node)
Returns the number of direct predecessors to node
Returns the number of direct predecessors to node
(in-edges g node)
Returns all the incoming edges of node
Returns all the incoming edges of node
(predecessors* g node)
Returns direct predecessors of node
Returns direct predecessors of node
(transpose g)
Returns a graph with all edges reversed
Returns a graph with all edges reversed
(digraph & inits)
Creates an unweighted, directed graph. inits can be edges, adjacency maps, or graphs
Creates an unweighted, directed graph. inits can be edges, adjacency maps, or graphs
(directed? g)
Returns true if g satisfies the Digraph protocol
Returns true if g satisfies the Digraph protocol
(dest edge)
Returns the dest node of the edge
Returns the dest node of the edge
(src edge)
Returns the source node of the edge
Returns the source node of the edge
(editable? g)
Returns true if g satisfies the EditableGraph protocol
Returns true if g satisfies the EditableGraph protocol
(add-edges* g edges)
Add edges to graph g. See add-edges
Add edges to graph g. See add-edges
(add-nodes* g nodes)
Add nodes to graph g. See add-nodes
Add nodes to graph g. See add-nodes
(remove-all g)
Removes all nodes and edges from graph g
Removes all nodes and edges from graph g
(remove-edges* g edges)
Removes edges from graph g. See remove-edges
Removes edges from graph g. See remove-edges
(remove-nodes* g nodes)
Remove nodes from graph g. See remove-nodes
Remove nodes from graph g. See remove-nodes
(fly-graph & {:keys [nodes edges successors predecessors weight start]})
Creates a read-only, ad-hoc graph which uses the provided functions to return values for nodes, edges, etc. If any members are not functions, they will be returned as-is. Edges can be inferred if nodes and successors are provided. Nodes and edges can be inferred if successors and start are provided.
Creates a read-only, ad-hoc graph which uses the provided functions to return values for nodes, edges, etc. If any members are not functions, they will be returned as-is. Edges can be inferred if nodes and successors are provided. Nodes and edges can be inferred if successors and start are provided.
(graph & inits)
Creates an unweighted, undirected graph. inits can be edges, adjacency maps, or graphs
Creates an unweighted, undirected graph. inits can be edges, adjacency maps, or graphs
(edges g)
Edges in g. May return each edge twice in an undirected graph
Edges in g. May return each edge twice in an undirected graph
(has-edge? g n1 n2)
Returns true when edge [n1 n2] is in g
Returns true when edge [n1 n2] is in g
(has-node? g node)
Returns true when node is in g
Returns true when node is in g
(nodes g)
Returns a collection of the nodes in graph g
Returns a collection of the nodes in graph g
(out-degree g node)
Returns the number of outgoing edges of node
Returns the number of outgoing edges of node
(out-edges g node)
Returns all the outgoing edges of node
Returns all the outgoing edges of node
(successors* g node)
Returns direct successors of node
Returns direct successors of node
(graph? g)
Returns true if g satisfies the Graph protocol
Returns true if g satisfies the Graph protocol
(predecessors g)
(predecessors g node)
Returns direct predecessors of node
Returns direct predecessors of node
(remove-edges g & edges)
Removes edges from graph g. Do not include weights
Removes edges from graph g. Do not include weights
(remove-nodes g & nodes)
Removes nodes from graph g
Removes nodes from graph g
(subgraph g ns)
Returns a graph with only the given nodes
Returns a graph with only the given nodes
(successors g)
(successors g node)
Returns direct successors of node
Returns direct successors of node
(weight g)
(weight g e)
(weight g n1 n2)
Returns the weight of edge e or edge [n1 n2]
Returns the weight of edge e or edge [n1 n2]
(weighted-digraph & inits)
Creates an weighted, directed graph. inits can be edges, adjacency maps, or graphs
Creates an weighted, directed graph. inits can be edges, adjacency maps, or graphs
(weighted-graph & inits)
Creates an weighted, undirected graph. inits can be edges, adjacency maps, or graphs
Creates an weighted, undirected graph. inits can be edges, adjacency maps, or graphs
(weighted? g)
Returns true if g satisfies the WeightedGraph protocol
Returns true if g satisfies the WeightedGraph protocol
(weight* g e)
(weight* g n1 n2)
Returns the weight of edge e or edge [n1 n2]
Returns the weight of edge e or edge [n1 n2]
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close