
aiddl.org.aiddl.common.math.graph.aiddl Maven / Gradle / Ivy
(#mod self org.aiddl.common.math.graph)
(#req EVAL org.aiddl.eval.namespace)
(#nms nms-basic basic-ops@EVAL)
(#nms nms-type type-ops@EVAL)
(#nms nms-logic logic-ops@EVAL)
(#nms nms-collection collection-ops@EVAL)
(#type Node term)
(#type UndirectedEdge (set-of ^$Node constraint:(lambda ?X (= 2 (size ?X)))))
(#type DirectedEdge (sig [^$Node ^$Node]))
(#type Edge (union [^$UndirectedEdge ^$DirectedEdge]))
(#type (TypedGraph ?NodeType)
(dict [V:(set-of ?NodeType) E:(set-of ^$Edge)]
constraint:(lambda ?X
(let [?V:(get-key V ?X) ?E:(get-key E ?X)]
(forall ?e ?E (contains-all ?V ?e) )))))
(#type (TypedDiGraph ?NodeType)
(dict [V:(set-of ?NodeType) E:(set-of ^$DirectedEdge)]
constraint:(lambda ?X
(let [?V:(get-key V ?X) ?E:(get-key E ?X)]
(forall (?u ?v) ?E (and (contains ?V ?u) (contains ?V ?v)))))))
(#type Graph ($TypedGraph ^$Node))
(#type DiGraph ($TypedDiGraph ^$Node))
(#type Path (list-of ^$Node))
(#type WeightMap (col-of (typed-kvp ^$Edge:^numerical)))
(#type DistanceMap (union {(enum {NIL}) (col-of (typed-kvp ^$Node:^numerical))}))
(#type PredecessorMap (union {(enum {NIL}) (col-of (typed-kvp ^$Node:^$Node))}))
(#type sssp-out (dict [distance:^$DistanceMap predecessor:^$PredecessorMap]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Interfaces
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(#interface single-source-shortest-path (
uri : org.aiddl.common.math.graph.single-source-shortest-path
input : (sig [^$DiGraph (union [^fun-ref ^$WeightMap]) ^$Node])
output : ^$sssp-out
))
(#interface depth-first-search (
uri : org.aiddl.common.math.graph.depth-first-search
input : ^$DiGraph
output : (dict [
pi:(set-of (typed-kvp ^$Node:^$Node))
distances:(set-of (typed-kvp ^$Node:^numerical))
finish-times:(set-of (typed-kvp ^$Node:^numerical))
components:(set-of (set-of ^$Node)) ]
)
))
(#interface strongly-connected-components (
uri : org.aiddl.common.math.graph.scc-computer
input : ^$DiGraph
output : (set-of (set-of ^$Node))
))
(#interface transpose (
uri : org.aiddl.common.math.graph.transpose
input : ^$DiGraph
output : ^$DiGraph
))
(#interface path-extractor (
uri : org.aiddl.common.math.graph.path-extractor
input : ^$PredecessorMap
output : ^$Path
))
© 2015 - 2025 Weber Informatics LLC | Privacy Policy