Algorithms for traversing the graph
Algorithms for traversing the graph
(add-default-params g opts)Standardize the options map for least-cost-path
Standardize the options map for least-cost-path
(find-multipath backlinks & targets)Given the final relation id in a path, return a sequence of relation ids or sets of relation ids from the initial node(s) to the final relation.
Given the final *relation id* in a path, return a sequence of relation ids or sets of relation ids from the initial node(s) to the final relation.
(least-cost-path g params)(least-cost-path g start-node end-node)(least-cost-path g start-node end-node cost-attr)Finds the cheapest path satisfying the given constraints. Respects mult-edge relations (idm.graph.relation/[one->one, many->one, one->many])
Arguments:
g: graph
params: map of parameters, with defaults provided by add-default-params
start-nodes: set of initial, known nodesend-nodes: set of nodes to end attraverse?: when true, requires all end-nodes be reached before
terminating; otherwise, terminates on first nodemay-final-edge? function indicating whether nor not a given edge may be
the last one in the pathcost-fn: function providing cost of a given edgenode-filter: function returning true for allowed nodesedge-filter: function returning true for allowed edgesfinal-node?: function instructing immediate termination for a node
returning true, provided its edge passes may-final-edge?If end-nodes not provided:
final-node? is provided, will exit on first matching node.
final-node? is otherwise not used.traverse? is assumed and all possible edges will be visited
before exiting
Otherwise, if traverse? is true, will attempt to visit all nodes in
end-nodes before exiting; if false, will exit on first node in end-nodes.Finds the cheapest path satisfying the given constraints. Respects mult-edge
relations (idm.graph.relation/[one->one, many->one, one->many])
Arguments:
`g`: graph
`params`: map of parameters, with defaults provided by `add-default-params`
- `start-nodes`: set of initial, known nodes
- `end-nodes`: set of nodes to end at
- `traverse?`: when true, requires all `end-nodes` be reached before
terminating; otherwise, terminates on first node
- `may-final-edge?` function indicating whether nor not a given edge may be
the last one in the path
- `cost-fn`: function providing cost of a given edge
- `node-filter`: function returning true for allowed nodes
- `edge-filter`: function returning true for allowed edges
- `final-node?`: function instructing immediate termination for a node
returning true, provided its edge passes `may-final-edge?`
If `end-nodes` not provided:
- and `final-node?` is provided, will exit on first matching node.
`final-node?` is otherwise not used.
- otherwise, `traverse?` is assumed and all possible edges will be visited
before exiting
Otherwise, if `traverse?` is true, will attempt to visit all nodes in
`end-nodes` before exiting; if false, will exit on first node in `end-nodes`.(pprint-multipath multipath)Pretty-print a multipath
Pretty-print a multipath
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 |