Core functions for accessing and manipulating TGraphs.

funnyqt.bidi | Bidirectional transformations (BX). |

funnyqt.coevo.tg | Co-Evolution transformations on TGraphs. |

funnyqt.edn | Printing/persisting and reading/loading query results and transformation
traces as EDN. |

funnyqt.emf | Core functions for accessing and manipulating EMF models. |

funnyqt.extensional | Specify models extensionally. |

funnyqt.generic | Generic protocols extended upon many different types, and generic functions. |

funnyqt.in-place | In-place transformation stuff. |

funnyqt.model2model | Rule-base out-place transformations similar to ATL or QVTo. |

funnyqt.pmatch | Graph Pattern Matching on arbitrary models. |

funnyqt.polyfns | Polymorphic functions dispatching on types of model elements. |

funnyqt.query | Generic query functions like regular path expressions & quantified expressions. |

funnyqt.query.emf | EMF-specific query functions |

funnyqt.query.tg | TG-specific query functions |

funnyqt.relational | Relational Model Querying. |

funnyqt.utils | Generic utility functions, e.g., for signaling errors, debugging, and profiling, |

funnyqt.visualization | Model visualization functions. |

funnyqt.xmltg | Convert XML to DOM-like TGraphs. |

Index Page | |

Alphabetic Var Index |

Core functions for accessing and manipulating TGraphs. Loading/Saving ============== See `load-graph`, `save-graph`, and `load-schema`. Graph Elements ============== For accessing elements, see `vertex`, `edge`, `first-vertex`, `next-vertex`, `first-edge`, `next-edge`, `first-inc`, and `next-inc`. For creating graphs and elements, see `new-graph`, `create-vertex!`, and `create-edge!`. Sequence Functions ================== The central elements of this namespace are the functions `vseq`, `eseq`, and `iseq`, which return lazy seqs of a graph's vertices or edges, or a lazy seq of a vertex's incidences. On that lazy seqs, we can simply use all the powerful clojure sequence functions like `filter`, `map`, `reduce`, and friends. For example, that's how we can pick out all the Locality vertices whose number of inhabitants is greater than 1000: (filter #(> (value % :inhabitants) 1000) (vseq my-route-graph 'localities.Locality)) Attributes ========== To access attribute values or record components, use the function `value`. To set them, use `set-value!`. All clojure collections and maps are automatically converted to JGraLab's pcollections. In case of RecordDomains and EnumDomains, whose values are instances of generated classes, there are the constructor functions `record` and `enum-constant`.

Arglists: ========= (after-inc? a b) Docstring: ========== Returns true iff `a` is defined after `b` in the incidence sequence of the current vertex.

Arglists: ========= (after? a b) Docstring: ========== Returns true iff `a` is defined after `b` in the global vertex/edge sequence.

Arglists: ========= (alpha e) Docstring: ========== Returns the start vertex of edge `e`.

Arglists: ========= (attributed-element-class ae) (attributed-element-class elem qname) Docstring: ========== Returns `ae`s AttributedElementClass or the AttributedElementClass with the given `qname` in the schema of `elem`. In the arity 2 version, `elem` may be an attributed element, an attributed element class, or a schema.

Arglists: ========= (attributed-element-class? aec) Docstring: ========== Returns logical true if `aec` is an AttributedElementClass.

Arglists: ========= (attributed-element? ae) Docstring: ========== Returns logical true if `ae` is an AttributedElement.

Arglists: ========= (before-inc? a b) Docstring: ========== Returns true iff `a` is defined before `b` in the incidence sequence of the current vertex.

Arglists: ========= (before? a b) Docstring: ========== Returns true iff `a` is defined before `b` in the global vertex/edge sequence.

Arglists: ========= (contains-edge? g e) Docstring: ========== Returns true if graph `g` contains edge `e`.

Arglists: ========= (contains-vertex? g v) Docstring: ========== Returns true if graph `g` contains vertex `v`.

Arglists: ========= (create-edge! g cls from to) (create-edge! g cls from to attr-map) Docstring: ========== Creates a new edge of type `cls` in `g` starting at `from` and ending at `to`. `cls` is an EdgeClass or a qualified name given as symbol. `attr-map` is an optional map from attribute name given as keyword to value to be set for that attribute.

Arglists: ========= (create-vertex! g cls) (create-vertex! g cls prop-map) Docstring: ========== Creates a new vertex of type `cls` in `g`. `cls` is a VertexClass or a qualified name given as symbol. `prop-map` is an optional map from property names given as keyword to values to be set.

Arglists: ========= (degree v) (degree v ts) (degree v ts ds) Docstring: ========== Returns the degree of vertex `v`, optionally restricted by `ts` and `ds`.

Arglists: ========= (domain attr) (domain elem qname) Docstring: ========== Returns the attribute `attr`s domain. In the arity 2 variant, returns the Domain with qualified name `qname` in the schema of `elem`. `elem` may be an AttributedElement, AttributedElementClass, or a Schema.

Arglists: ========= (ecount g) (ecount g ts) Docstring: ========== Returns the edge count of `g` restricted by `ts`.

Arglists: ========= (edge g id) Docstring: ========== Returns `g`s edge with the given `id`. If `id` is negative, returns the reversed edge whose ID equals (abs id).

Arglists: ========= (edge-class? ec) Docstring: ========== Returns logical true if `ec` is an EdgeClass.

Arglists: ========= (edge? e) Docstring: ========== Returns logical true if `e` is an Edge.

Arglists: ========= (enum-constant ae qname) Docstring: ========== Returns the enum constant `qname` in the schema of attributed element `ae`. `qname` is the qualified name of the constant, e.g., my.Enum.CONSTANT.

Arglists: ========= (eseq g) (eseq g ts) Docstring: ========== Returns the lazy seq of edges of `e` restricted by `ts`. `g` may be a graph or an edge. In the latter case, returns all edges following `g` in the edge sequence.

Arglists: ========= (esubgraph g pred) (esubgraph g pred precalc) Docstring: ========== Returns an edge induced subgraph of `g` restricted by `pred` in terms of a TraversalContext. `pred` may be a predicate that is used to filter the edges of `g`, a type specification (see `type-spec`) or a collection of edges. The subgraph contains all edges matching the predicate including their start and end vertices. If `precalc` is true (the default), then pre-calculate the accepted elements beforehand as a SubGraphMarker. That speeds up the procedure enormously, but doesn't allow for using the returned traversal context on a graph that changes in between. Also see `vsubgraph` and `on-subgraph`.

Arglists: ========= (first-edge g) (first-edge g pred) Docstring: ========== Returns the first edge of graph `g`. May be restricted to the first edge for which `pred` returns true.

Arglists: ========= (first-inc v) (first-inc v pred) Docstring: ========== Returns the first incidence in iseq of `v`. May be restricted to the first incidence for which `pred` returns true.

Arglists: ========= (first-vertex g) (first-vertex g pred) Docstring: ========== Returns the first vertex of graph `g`. May be restricted to the first vertex for which `pred` returns true.

Arglists: ========= (generate-schema-functions schema-file) (generate-schema-functions schema-file nssym) (generate-schema-functions schema-file nssym alias) (generate-schema-functions schema-file nssym alias prefix) Docstring: ========== Generates a schema-specific API consisting of functions for creating vertices and edges and functions for accessing properties (attributes and roles). `schema-file` is the TG file containing the schema to generate an API for. `nssym` denotes the new namespace in which to generate the API. It may be nil in which case the current namespace is used. `alias` is an alias under which the new generated namespace is required. `prefix` is an optional prefix added to all functions of the generated API. (That's mostly useful when generating in the current namespace.) The API consists of the following functions. For any VertexClass Foo, there is a (create-Foo! graph) function, a (vseq-Foo graph) sequence function, and a (isa-Foo? v) type check predicate. For any EdgeClass HasFoo, there is a (create-HasFoo! graph alpha omega) function, (eseq-HasFoo graph) and (iseq-HasFoo v ds) sequence functions, and a (isa-HasFoo? e) type check predicate. For any attribute attr, there are the following functions: (attr el) ;; returns the attr value of el (set-attr! el val) ;; sets the attr value of el to val For boolean attributes attr, the getter is named (attr? el). For any role name role, there are the functions: (->role el) ;; returns the vertex/vertices in el's role (->set-role! el v) ;; sets the role (->add-role! el v1 v2 v3...) ;; adds v1, v2, and v3 to el's role (->addall-role! el vs) ;; adds all vertices in vs to el's role The add-* functions are only generated if role occurs as a multi-valued role for some VertexClass. If role is a multi-valued role of el, then the setter must be given a collection of vertices, else a single vertex.

Arglists: ========= (graph ge) Docstring: ========== Returns the graph containing the graph element `ge`.

Arglists: ========= (graph-class? gc) Docstring: ========== Returns logical true if `gc` is a GraphClass.

Arglists: ========= (graph-element-class? gec) Docstring: ========== Returns logical true if `gec` is a GraphElementClass.

Arglists: ========= (graph-element? ge) Docstring: ========== Returns logical true if `ge` is a GraphElement.

Arglists: ========= (graph? g) Docstring: ========== Returns logical true if `g` is a Graph.

Arglists: ========= (id elem) Docstring: ========== Returns this element's ID. For a Graph it is a string, for vertices and edges its an integer.

Arglists: ========= (inverse-edge e) Docstring: ========== Returns the normal edge of a reversed edge, or the reversed edge of a normal edge.

Arglists: ========= (iseq v) (iseq v ts) (iseq v ts ds) Docstring: ========== Returns the lazy seq of incidences of `v` restricted by `ts` and `ds`. `v` may be a vertex or an edge. In the latter case, returns all incidences following `v` in the current vertex's incidence sequence. `ts` is a type specification (see `funnyqt.generic/type-matcher`) and `ds` is a direction specification (see `funnyqt.generic/direction-matcher`). In fact, `ts` may also be a keyword naming a far-end role name, but this feature is only an implementation detail.

Arglists: ========= (last-edge g) (last-edge g pred) Docstring: ========== Returns the last edge of graph `g`. May be restricted to the last edge for which `pred` returns true.

Arglists: ========= (last-inc v) (last-inc v pred) Docstring: ========== Returns the last incidence in iseq of `v`. May be restricted to the last incidence for which `pred` returns true.

Arglists: ========= (last-vertex g) (last-vertex g pred) Docstring: ========== Returns the last vertex of graph `g`. May be restricted to the last vertex for which `pred` returns true.

Arglists: ========= (load-graph file) (load-graph file impl) Docstring: ========== Loads a graph from `file` using ImplementationType `impl`, defauling to :generic. The schema will be compiled automagically if needed. Supported impl types are :generic and :standard.

Arglists: ========= (load-schema file) (load-schema file impl) Docstring: ========== Loads a schema from `file`, and possibly compile it for implementation type `impl` (default :generic, i.e., don't compile). Supported impl types are :generic and :standard.

Arglists: ========= (merge-traversal-contexts tc1 tc2 combine-fn) Docstring: ========== Returns a TraversalContext that accepts only elements that are accepted by (combine-fn (tc1 el) (tc2 el)). (Don't use this direcly, but use `on-subgraph-intersection` and `on-subgraph-union'.)

Arglists: ========= (new-graph schema) (new-graph schema gid) (new-graph schema gid impl) Docstring: ========== Creates a graph with id `gid` of the given `schema` using implementation type `impl`. Supported impl types are :generic and :standard. The graph id defaults to a creation timestamp, and the impl type to GENERIC.

Arglists: ========= (next-edge e) (next-edge e pred) Docstring: ========== Returns the edge following `e` in eseq. May be restricted to the next edge for which `pred` returns true.

Arglists: ========= (next-inc e) (next-inc e pred) Docstring: ========== Returns the incidence following `e` in the current vertex's iseq. May be restricted to the next incidence for which `pred` returns true.

Arglists: ========= (next-vertex v) (next-vertex v pred) Docstring: ========== Returns the vertex following `v` in vseq. May be restricted to the next vertex for which `pred` returns true.

Arglists: ========= (normal-edge e) Docstring: ========== Returns `e`s normal (forward-oriented) edge.

Arglists: ========= (normal-edge? e) Docstring: ========== Returns true, iff `e` is normal (forward-oriented).

Arglists: ========= (omega e) Docstring: ========== Returns the end vertex of edge `e`.

Arglists: ========= (on-graph [g] & body) Docstring: ========== Disables the graph `g`s current traversal context for the execution of `body`. Guaranteed to restore the old traversal context after `body` finished (even if it errored). Also see `on-subgraph`, and `on-subgraph-intersection`.

Arglists: ========= (on-subgraph [g tc] & body) Docstring: ========== Sets the TraversalContext of `g` to `tc` and then executes `body`. Guaranteed to restore the old TraversalContext after `body` finished (even if it errored). Also see `vsubgraph`, `esubgraph`, and `on-subgraph-intersection`.

Arglists: ========= (on-subgraph-intersection [g tc] & body) Docstring: ========== Sets the TraversalContext of `g` to a new TraversalContext that accepts only elements which both `tc` and `g`s current TraversalContext accept and then executes `body`. Guaranteed to restore the old TraversalContext. Also see `vsubgraph`, `esubgraph`, `on-subgraph`, and `on-subgraph-union'.

Arglists: ========= (on-subgraph-union [g tc] & body) Docstring: ========== Sets the TraversalContext of `g` to a new TraversalContext that accepts only elements which `tc` or `g`s current TraversalContext accept and then executes `body`. Guaranteed to restore the old TraversalContext. Also see `vsubgraph`, `esubgraph`, `on-subgraph`, and `on-subgraph-intersection'.

Arglists: ========= (prev-edge e) (prev-edge e pred) Docstring: ========== Returns the edge preceding `e` in eseq. May be restricted to the previous edge for which `pred` returns true.

Arglists: ========= (prev-inc e) (prev-inc e pred) Docstring: ========== Returns the incidence preceding `e` in the current vertex's iseq. May be restricted to the previous incidence for which `pred` returns true.

Arglists: ========= (prev-vertex v) (prev-vertex v pred) Docstring: ========== Returns the vertex preceding `v` in vseq. May be restricted to the previous vertex for which `pred` returns true.

Arglists: ========= (put-after! a b) Docstring: ========== Puts `a` directly after `b` in the graph's vertex/edge sequence.

Arglists: ========= (put-after-inc! a b) Docstring: ========== Puts `a` directly after `b` in the current vertex's incidence sequence.

Arglists: ========= (put-before! a b) Docstring: ========== Puts `a` directly before `b` in the graph's vertex/edge sequence.

Arglists: ========= (put-before-inc! a b) Docstring: ========== Puts `a` directly before `b` in the current vertex's incidence sequence.

Arglists: ========= (record ae qname m) Docstring: ========== Creates a record of type `qname` in the schema of attributed element `ae` with component values as specified by map `m`, a map from keywords to values. The map `m` must specify all components. Be sure to provide integer values as `(int val)` when a record component has domain Integer.

Arglists: ========= (relink! from to) (relink! from to ts) (relink! from to ts ds) Docstring: ========== Relinks all incidences of vertex `from` to vertex `to` and returns `from`. The incidences can be restricted by type spec `ts` and `ds` (see `funnyqt.generic/type-matcher` and `funnyqt.generic/direction-matcher`).

Arglists: ========= (reseq g) (reseq g ts) Docstring: ========== Returns the lazy reversed seq of edges of `e` restricted by `ts`. `g` may be a graph or an edge. In the latter case, returns all edges preceding `g` in the edge sequence.

Arglists: ========= (reset-all-tg-caches) Docstring: ========== Resets all TG specific caches: 1. the +type-matcher-cache+

Arglists: ========= (reversed-edge e) Docstring: ========== Returns `e`s reversed (backward-oriented) edge.

Arglists: ========= (riseq v) (riseq v ts) (riseq v ts ds) Docstring: ========== Returns the lazy reversed seq of incidences of `v` restricted by `ts` and `ds`. `v` may be a vertex or an edge. In the latter case, returns all incidences preceding `v` in the current vertex's incidence sequence. `ts` is a type specification (see `funnyqt.generic/type-matcher`) and `ds` is a direction specification (see `funnyqt.generic/direction-matcher`). In fact, `ts` may also be a keyword naming a far-end role name, but this feature is only an implementation detail.

Arglists: ========= (rvseq g) (rvseq g ts) Docstring: ========== Returns the lazy reversed seq of vertices of `g` restricted by the type spec `ts`. `g` may be a graph or a vertex. In the latter case, returns all vertices preceding `g` in the vertex sequence.

Arglists: ========= (save-graph g file) Docstring: ========== Saves graph `g` to `file`.

Arglists: ========= (save-schema g file) Docstring: ========== Saves schema `s` to `file`.

Arglists: ========= (schema elem) Docstring: ========== Returns the schema of `elem` (an AttributedElement, AttributedElementClass, or a Domain).

Arglists: ========= (schema-graph s) Docstring: ========== Returns the SchemaGraph of schema `s`.

Arglists: ========= (schema? s) Docstring: ========== Returns logical true if `s` is a Schema.

Arglists: ========= (set-alpha! e v) Docstring: ========== Sets the start vertex of `e` to `v` and returns `e`.

Arglists: ========= (set-omega! e v) Docstring: ========== Sets the end vertex of `e` to `v` and returns `e`.

Arglists: ========= (set-that! i v) Docstring: ========== Sets the that vertex of `i` to `v` and returns `i`.

Arglists: ========= (set-this! i v) Docstring: ========== Sets the this vertex of `i` to `v` and returns `i`.

Arglists: ========= (set-value! ae attr val) Docstring: ========== Sets `ae`s (an attributed element) `attr` value to `val` and returns `ae`.

Arglists: ========= (tgtree g) Docstring: ========== Shows a simple Swing tree view representation of the graph `g`.

Arglists: ========= (that e) Docstring: ========== Returns `e`s that-vertex.

Arglists: ========= (this e) Docstring: ========== Returns `e`s this-vertex.

Arglists: ========= (unlink! v) (unlink! v ts) (unlink! v ts ds) Docstring: ========== Unlinks the given vertex, i.e., deletes all incident edges matching `ts` and `ds`.

Arglists: ========= (value ae-or-rec attr-or-comp) Docstring: ========== Returns `ae-or-rec`s (an attributed element or record) `attr-or-comp` value.

Arglists: ========= (vcount g) (vcount g ts) Docstring: ========== Returns the vertex count of `g` restricted by `ts`.

Arglists: ========= (vertex g id) Docstring: ========== Returns `g`s vertex with the given `id`.

Arglists: ========= (vertex-class? vc) Docstring: ========== Returns logical true if `vc` is a VertexClass.

Arglists: ========= (vertex? v) Docstring: ========== Returns logical true if `v` is a Vertex.

Arglists: ========= (vseq g) (vseq g ts) Docstring: ========== Returns the lazy seq of vertices of `g` restricted by the type spec `ts`. `g` may be a graph or a vertex. In the latter case, returns all vertices following `g` in the vertex sequence.

Arglists: ========= (vsubgraph g pred) (vsubgraph g pred precalc) Docstring: ========== Returns a vertex induced subgraph of `g` restricted by `pred` in terms of a TraversalContext. `pred` may be a predicate that is used to filter the vertices of `g`, a type specification (see `type-spec`) or a collection of vertices. The subgraph contains all vertices matching the predicate, and all edges/incidences that are connected to vertices that are both in the subgraph. If `precalc` is true (the default), then pre-calculate the accepted elements beforehand as a SubGraphMarker. That speeds up the procedure enormously, but doesn't allow for using the returned traversal context on a graph that changes in between. Also see `esubgraph` and `on-subgraph`.