Skip to main content

Crate facett_graph

Crate facett_graph 

Source
Expand description

facett-graph — the graph (node/edge) viewer component, on facett_core. Build a Scene from a labelled edge list (the common shape: a graph query, a dataflow DAG) and draw it. Source-agnostic — the caller turns its Arrow/Cypher/whatever into edges first.

§FC contract (the canonical Elm split, FC-2 / FC-9)

Both facets in this crate — GraphView (the 2D node/edge skin) and DepGraphView (the layered dep-DAG) — adopt the facett_core::Elm split:

  • GraphState / depgraph::DepGraphState — the complete observable, serializable, round-trippable interaction state. The bulk graph data (the Scene / the nodes+edges) is the input held on the struct — Color32 is not serde-round-trippable and it is not the state a headless driver mutates, so it lives OUTSIDE the Model (mirrors how facett-grid keeps its Arrow data on the struct, not in its GridState).
  • Msg + update — the single mutation path (FC-2): a host/robot toggles the layout (GraphView) or selects/clears a node (DepGraphView); a headless driver (facett_core::harness) reaches the identical transitions.
  • view — a pure paint (FC-9): reads &self, paints, and returns the Msgs the interactions produced; the impl_facet_via_elm! bridge applies them.
  • Rich state_json — the node/edge/label counts (and the dep-graph’s column depth) a driver reads are derived from the input Scene/nodes, not the interaction Model, so the macro is invoked in form 3 (custom_state_json) to publish those exact pre-migration keys instead of a plain serde(state()).

Modules§

theme
Theming. A palette the custom-painted components (graph/depgraph/map) read from the egui context, plus matching egui Visuals for the standard widgets (pop/table/pipeline). Call set_theme once on the context and every facet follows. Ships a Theme::default look, a Theme::sci_fi neon-on-near-black look, and a switchable family of striking palettes (Theme::nordic_aurora, Theme::cyberpunk_neon, Theme::amber_crt, Theme::deep_space, Theme::hugin_noir). Enumerate them with Theme::ALL / Theme::by_name to build a picker.

Structs§

DepEdge
A directed edge from → to, with the connecting items shown on the arrow.
DepGraphState
The complete observable interaction state (FC-1 / FC-3) of a DepGraphView: the drilled-in selection, keyed on the node’s stable label (FC-5) so a reorder/insert/delete can’t silently re-point it the way a list index would. The nodes/edges are input on DepGraphView, kept out of this Model.
DepGraphView
The layered dep-graph viewer. Implements [Facet].
DepNode
One node: a label, an optional sub-label (a sha, a version…), and a border colour (the consumer’s status policy).
Edge
A directed edge between node indices.
FacetCaps
What a Facet can do, so hosts treat every component uniformly. All-false by default: a facet opts in to each capability it actually honors.
GraphState
The complete observable interaction state (FC-1 / FC-3) of a GraphView: the layout knob a host can toggle. The bulk Scene is input held on GraphView (not serde-round-trippable, not driver-mutated), so it is deliberately kept OUT of this Model — the derived node/edge/label counts a driver reads are published via the form-3 state_json instead.
GraphView
A simple graph-view widget: a Scene + a Layout. Implements Facet, so it drops into a FacetDeck and exposes state_json for free.
Node
A node: a label + a colour (the consumer picks the colour policy — hash by label, by status, …).
Scene
A drawable graph: nodes + edges (edges index into nodes).
Theme
The facett palette. All custom-painted colours come from here.

Enums§

DepGraphEffect
Side work as data (FC-8). The dep-graph does no I/O — every Msg mutates only the in-memory DepGraphState — so this is uninhabited on purpose.
DepGraphMsg
A robot-/CLI-addressable control message (FC-2) — the named boundary a headless driver (or a host) drives the graph through, the same effect a node-box click produces. Applied by DepGraphView::update.
Effect
Side work as data (FC-8). The graph view does no I/O — every Msg mutates only the in-memory GraphState — so this is uninhabited on purpose.
GraphLayout
A serde-round-trippable mirror of Layout (which is Copy but neither Serialize nor Debug, so it cannot live in the GraphState Model directly). The Msg and the Model carry this; conversions to/from the core Layout keep the painter and public API speaking the core type.
Layout
Node placement strategy.
Msg
A robot-/CLI-addressable control message (FC-2) — the named boundary a headless driver (or a host) drives the GraphView through. Applied by GraphView::update.

Traits§

Facet
The facett component contract. Every facet — graph, map, pipeline, table, the ported nornir viewers — implements this, so consumers (korp, nornir, …) compose them uniformly and get headless robot-testing for free.

Functions§

draw
Draw a Scene into ui — the reusable render primitive. Empty scenes show empty_hint. Labels render when the node count is small enough to read.
draw_arrow
Line + arrowhead from from to to (head pulled back by half a node width).
hash_color
A stable, bright-ish colour from a string (FNV-1a). Handy default node colour.
scene_from_labeled_edges
Build a Scene from a labelled edge list — each row is (src_id, dst_id, src_label, dst_label). Distinct ids become nodes, coloured per label (FNV-hashed). The reusable “graph from edges” adapter korp’s Graph and Pipelines views both want.
set_theme
Store theme on the context and apply its egui Visuals. Call once per frame (cheap) or whenever the theme changes; every facet picks it up.
theme
The theme stored on the ui’s context (or Theme::default if none).