Simple graph functions for graphs in adjacency map form.
Simple graph functions for graphs in adjacency map form.
(append-edge g [from to])
Appends an edge to a graph.
Appends an edge to a graph.
(append-path g path)
Appends a path onto a graph.
Appends a path onto a graph.
(bidirectional g)
Returns a new graph where all edges go both directions.
Returns a new graph where all edges go both directions.
(branches g)
Returns the branches of the tree.
Returns the branches of the tree.
(complement g)
Returns the difference between fully connected g and g
Returns the difference between fully connected g and g
(complete g)
Returns the fully connected variant of g
Returns the fully connected variant of g
(connected? g)
Can you navigate from any starting node to any other node?
Can you navigate from any starting node to any other node?
(consumers g)
Get all nodes with inbound edges.
Get all nodes with inbound edges.
(contractg pred g)
Removes nodes that match pred and adds new edges between inbound and outbound neighbors of each node impacted (leaves the transitive closure otherwise intact).
Removes nodes that match pred and adds new edges between inbound and outbound neighbors of each node impacted (leaves the transitive closure otherwise intact).
(cyclical? g)
Are there cycles in this graph?
Are there cycles in this graph?
(defgn symbol docs bindings & body)
Like defn but handles normalizing any 'g or g{digit}' arguments first.
Like defn but handles normalizing any 'g or g{digit}' arguments first.
(degree g n)
How many edges does this node have?
How many edges does this node have?
(edges g)
Get the set of edges of graph g.
Get the set of edges of graph g.
(empty g)
Returns a graph with the same nodes as g but no edges.
Returns a graph with the same nodes as g but no edges.
(exclusive? g1 g2)
Returns whether the graphs don't overlap.
Returns whether the graphs don't overlap.
(expandg f g)
Expand nodes into more nodes while maintaining all the same edges between any new nodes.
Expand nodes into more nodes while maintaining all the same edges between any new nodes.
(exterior g)
Returns the exterior nodes of the graph.
Returns the exterior nodes of the graph.
(filterg pred g)
Only keep nodes in the graph that satisfy pred. All inbound and outbound edges involving removed nodes are also removed.
Only keep nodes in the graph that satisfy pred. All inbound and outbound edges involving removed nodes are also removed.
(graph edges)
(graph nodes edges)
Create a graph from a set of edges
Create a graph from a set of edges
(incoming-degree g n)
Gets the incoming degree of n.
Gets the incoming degree of n.
(incoming-edges g n)
Get all edges that go from another node to n.
Get all edges that go from another node to n.
(incoming-neighbors g n)
Gets the neighbors of n from any inbound edges.
Gets the neighbors of n from any inbound edges.
(interior g)
Returns the interior nodes of the graph.
Returns the interior nodes of the graph.
(intersect? g1 g2)
Returns whether the graphs overlap.
Returns whether the graphs overlap.
(inverse g)
Invert the graph by reversing all edges.
Invert the graph by reversing all edges.
(leaves g)
Returns the leaves of the tree.
Returns the leaves of the tree.
(mapg f g)
Transform nodes in the graph according to f.
Transform nodes in the graph according to f.
(neighbors g n)
Gets all the neighbors of n.
Gets all the neighbors of n.
(nodes g)
Get all nodes from the graph g.
Get all nodes from the graph g.
(normalize g)
Given an adjacency with potentially missing entries, populate the entries based on the appearance of other nodes on the right side of an edge. Tags the result with metadata so it doesn't recompute for repeat invocations.
Given an adjacency with potentially missing entries, populate the entries based on the appearance of other nodes on the right side of an edge. Tags the result with metadata so it doesn't recompute for repeat invocations.
(outgoing-degree g n)
Gets the outgoing degree of n.
Gets the outgoing degree of n.
(outgoing-edges g n)
Get all edges that go from n to another node.
Get all edges that go from n to another node.
(outgoing-neighbors g n)
Gets the neighbors of n from any outbound edges.
Gets the neighbors of n from any outbound edges.
(producers g)
Get all nodes with outbound edges.
Get all nodes with outbound edges.
(remove-edge g [from to])
Removes an edge from a graph.
Removes an edge from a graph.
(remove-path g path)
Removes a path from a graph.
Removes a path from a graph.
(removeg pred g)
Remove nodes in the graph that satisfy pred. All inbound and outbound edges involving removed nodes are also removed.
Remove nodes in the graph that satisfy pred. All inbound and outbound edges involving removed nodes are also removed.
(root g)
Returns the root of the graph if any, else nil.
Returns the root of the graph if any, else nil.
(select g from)
Return the subgraph of g that is within reach of 'from'
Return the subgraph of g that is within reach of 'from'
(shortest-paths g & [weight-fn])
Uses Floyd-Warshall to returns a map of {[source destination] {:distance <num> :path [source ... destination]}} for the given graph. Uses weight-fn (a function of two nodes) to assign a cost to edges.
Uses Floyd-Warshall to returns a map of {[source destination] {:distance <num> :path [source ... destination]}} for the given graph. Uses weight-fn (a function of two nodes) to assign a cost to edges.
(sink? g n)
Is n a node with no outgoing edges?
Is n a node with no outgoing edges?
(sinks g)
Get all nodes with no outbound edges.
Get all nodes with no outbound edges.
(source? g n)
Is n a node with no incoming edges?
Is n a node with no incoming edges?
(sources g)
Get all nodes with no inbound edges.
Get all nodes with no inbound edges.
(supergraph? g1 g2)
Is g1 a supergraph of g2?
Is g1 a supergraph of g2?
(symmetric-difference g1 g2)
Returns the union of the exclusive sections of g1 and g2.
Returns the union of the exclusive sections of g1 and g2.
(topological-sort g)
Returns a topological sort of the adjacency map
Returns a topological sort of the adjacency map
(topological-sort-with-grouping g)
Returns a topological sort of the adjacency map and partition items into sets where order is arbitrary.
Returns a topological sort of the adjacency map and partition items into sets where order is arbitrary.
(transitive-closure g)
Creates new edges on g such that every node connects directly to any node that could previously have been connected indirectly.
Creates new edges on g such that every node connects directly to any node that could previously have been connected indirectly.
(walk? g [x1 x2 & xs])
Check if the given walk is valid for the graph.
Check if the given walk is valid for the graph.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close