Skip to main content

Graph

Struct Graph 

Source
pub struct Graph { /* private fields */ }
Expand description

Main graph structure backed by petgraph::StableGraph

Implementations§

Source§

impl Graph

Source

pub fn table_stats(&self) -> GraphTableStats

Cheap live counts for the graph’s kernel-owned tables.

Source§

impl Graph

Source

pub fn copy_node_from( &mut self, source: &Node, source_graph: Option<String>, position: Point2D<f32>, ) -> NodeKey

Copy source’s content into this graph, minting a fresh node and recording cross-graph derivation provenance back to the source.

source is a donor Node from another Graph; source_graph is the donor graph’s id (the constellation GraphId rendered as a string), or None when unknown / same-graph. The copy is a new entity: it gets a fresh identity, and its content (title, tags, classifications, open properties, address, visuals, viewer preferences) is cloned, while its identity / runtime / session / arrangement state is reset (fresh id, unpinned, no frame hints; browser-runtime state lives in the host’s BrowserNodeState sidecar and never travels with a copy). A NodeDerivation records (CopiedFrom, source.id, source_graph) so the lineage survives and projects to a wasDerivedFrom statement.

The donor’s import_provenance is intentionally not carried over: that describes how the donor entered its graph from an external source; the copy’s provenance is the derivation record, not the donor’s import.

Not available on wasm32 (mints a random id, like add_node); use copy_node_from_with_id with a host-provided UUID there.

Source

pub fn copy_node_from_with_id( &mut self, id: Uuid, source: &Node, source_graph: Option<String>, _position: Point2D<f32>, ) -> NodeKey

copy_node_from with a caller-supplied id (the wasm-clean entry point, mirroring add_node_with_id).

Source

pub fn copy_node_from_xy( &mut self, source: &Node, source_graph: Option<String>, x: f32, y: f32, ) -> NodeKey

copy_node_from taking plain x / y screen-graph coords, so a host can place the copy without depending on euclid. (Tear-out gestures G5.)

Source

pub fn copy_component_from( &mut self, source: &Graph, seed: Uuid, source_graph: Option<String>, ) -> ComponentCopy

Copy the connected component containing seed (a node in source) into this graph: the kernel half of a tear-out fork (the reachable-subgraph snapshot, tear-out brief §4.3). Each node is minted fresh (with a CopiedFrom NodeDerivation back to its source); the component’s internal edges are re-pointed onto the new nodes by cloning each edge’s payload verbatim. Edges leaving the component are dropped (the snapshot is closed under the component). Returns the ComponentCopy: the new keys plus the source id → new id remap the host’s facet-carry maps donor facets through (G4-R R0 — positions and every other per-node character ride arrangement.* / web.* / … facets, not the graph, so the fork’s layout carry needs this mapping). (Tear-out gestures G4.)

Source§

impl Graph

Source§

impl Graph

Source

pub fn facets(&self) -> &NodeFacetStore

The graph’s single live atomic-facet authority.

Source

pub fn facets_mut(&mut self) -> &mut NodeFacetStore

Mutable facet access for the host and extension gate.

Kernel-owned facet families should still use their typed graph methods; this surface exists for host-defined and unknown-forward namespaces.

Source

pub fn overlay_facets(&mut self, facets: NodeFacetStore)

Overlay a canonical sidecar after snapshot load.

Legacy snapshot columns are imported while reconstructing the graph. Existing facets.json values then win for matching keys, while both stores preserve unrelated namespaces.

Source§

impl Graph

Source

pub fn bear_nested(&mut self, key: NodeKey, nested: Option<LogId>) -> bool

Directly bear (or clear) a nested graph on a node WITHOUT running the delta spine — for copy/load paths building a graph that has no journal yet (a fork re-bearing the worlds it carried as real file copies; the component copy itself deliberately drops nested so two LIVE nodes never share one world). Journaled edits go through GraphDelta::SetNodeNested instead.

Source

pub fn frame_layout_hints(&self, key: NodeKey) -> Option<Vec<FrameLayoutHint>>

Source

pub fn frame_split_offer_suppressed(&self, key: NodeKey) -> Option<bool>

Source

pub fn node_is_pinned(&self, key: NodeKey) -> Option<bool>

Source

pub fn node_tags(&self, key: NodeKey) -> Option<&HashSet<String>>

Source

pub fn node_tag_presentation( &self, key: NodeKey, ) -> Option<NodeTagPresentationState>

Source

pub fn node_import_provenance( &self, key: NodeKey, ) -> Option<Vec<NodeImportProvenance>>

Source

pub fn node_classifications( &self, key: NodeKey, ) -> Option<Vec<NodeClassification>>

Source

pub fn node_properties(&self, key: NodeKey) -> Option<Vec<NodeProperty>>

Source

pub fn node_derivations(&self, key: NodeKey) -> Option<Vec<NodeDerivation>>

Source

pub fn node_last_visited(&self, key: NodeKey) -> Option<SystemTime>

Source

pub fn node_last_session_visited(&self, key: NodeKey) -> Option<u64>

Source§

impl Graph

Source

pub fn field(&self, id: FieldId) -> Option<&Field>

The field with this id, if any.

Source

pub fn fields(&self) -> impl Iterator<Item = &Field>

All fields, in unspecified order.

Source

pub fn couplings(&self) -> impl Iterator<Item = &Coupling>

All couplings, in unspecified order.

Source

pub fn couplings_for_field( &self, field: FieldId, ) -> impl Iterator<Item = &Coupling> + '_

Couplings whose target is the given field.

Source

pub fn field_coupling_strength(&self, field: FieldId) -> Option<f32>

The strength of the first coupling targeting field, if any (a field carries one default coupling). For the roster’s per-field strength readout. (Field regions — strength tuning.)

Source

pub fn nodes_matching<'a>( &'a self, selector: &'a NodeSelector, ) -> impl Iterator<Item = NodeKey> + 'a

Resolve a coupling’s NodeSelector to the matching nodes, against node tags and classifications. Kind(k) matches a node carrying any classification whose value is k (the v1 interpretation; a scheme-qualified match can refine it later).

Source§

impl Graph

Source

pub fn collect_node_traversals( &self, key: NodeKey, ) -> Option<Vec<DissolvedTraversalRecord>>

Collect traversals from all incident edges without mutating graph state.

Source

pub fn assert_semantic_statement( &mut self, from: NodeKey, to: NodeKey, spec: SemanticStatementSpec, ) -> Option<(EdgeKey, StatementAssert)>

Statement-aware assert (petgraph-RDF Phase 1 write API): assert one semantic statement with full per-statement metadata on the (from, to) pair bucket, creating the bucket edge if absent. Content-dedup returns the EXISTING fact handle (updating its metadata in place); a genuine change bumps the revision. None only when an endpoint is missing.

Source

pub fn assert_persisted_semantic_statement( &mut self, from: NodeKey, to: NodeKey, statement: SemanticStatement, ) -> Option<EdgeKey>

Assert a semantic statement whose id is ALREADY minted — the re-ingest / round-trip path (a reifier carried the fact handle, and preserving it is what makes RDF -> kernel -> RDF id-stable). Same content-dedup as the persisted-snapshot load; endpoints must exist.

Source

pub fn retract_semantic_statement( &mut self, from: NodeKey, to: NodeKey, statement_id: &str, ) -> bool

Precise retract by fact handle (the id assert_semantic_statement returned, also carried on every projected reifier). Removes the statement from the pair bucket; an emptied payload removes the petgraph edge itself, so “there is an edge A -> B” keeps meaning “at least one fact or other family payload exists on the pair”.

Source

pub fn get_edge(&self, key: EdgeKey) -> Option<&EdgePayload>

Get an edge payload by key.

Source

pub fn find_edge_key(&self, from: NodeKey, to: NodeKey) -> Option<EdgeKey>

Find the first directed edge key between two nodes.

Source§

impl Graph

Source

pub fn get_node(&self, key: NodeKey) -> Option<&Node>

Get a node by key

Source

pub fn find_node_by_address( &self, address: &Address, ) -> Option<(NodeKey, &Node)>

Find a node whose AddressClaims include the given address (any AddressRole). Returns an arbitrary matching node when multiple nodes share the address — the caller is expected to handle duplicates explicitly when relevant.

Canonical address lookup per the node identity + duplicates brief; supersedes the URL-string-keyed get_node_by_url (which is retained as a transitional shim — see below).

Source

pub fn get_node_by_url(&self, url: &str) -> Option<(NodeKey, &Node)>

Convenience wrapper over Graph::find_node_by_address for callers that have a URL string rather than a typed [Address]. Builds the [Address] internally and delegates.

Use this for tests and quick lookups; prefer Graph::find_node_by_address in code paths that already have a typed [Address] in hand.

Source

pub fn get_nodes_by_url(&self, url: &str) -> Vec<NodeKey> ⓘ

Get all node keys currently mapped to a URL.

Source

pub fn get_node_by_id(&self, id: Uuid) -> Option<(NodeKey, &Node)>

Get a node by UUID.

Source

pub fn get_node_key_by_id(&self, id: Uuid) -> Option<NodeKey>

Get node key by UUID.

Source

pub fn nodes(&self) -> impl Iterator<Item = (NodeKey, &Node)>

Iterate over all nodes as (key, node) pairs

Source

pub fn relations(&self) -> impl Iterator<Item = RelationView> + '_

Iterate over all stored relations, one row per recognized statement/family carried by the pair-local edge bucket. One EdgePayload between two nodes may therefore yield multiple semantic rows.

Canonical read surface per the 2026-05-11 relation-taxonomy plan §2. Stage 4 removed the legacy EdgeType-flavoured edges() iterator that this replaces.

Source

pub fn semantic_edges(&self) -> impl Iterator<Item = SemanticEdgeView> + '_

Source

pub fn arrangement_edges( &self, ) -> impl Iterator<Item = ArrangementEdgeView> + '_

Source

pub fn containment_edges( &self, ) -> impl Iterator<Item = ContainmentEdgeView> + '_

Source

pub fn derive_containment_for(&mut self, key: NodeKey)

Rebuild derived containment edges from current node URLs.

Derived relations are additive/read-only and are never persisted. Derive the containment this one node’s address implies, at the moment the node is created.

The UrlPath half of [rebuild_derived_containment_relations], applied to a single node. It exists because that rebuild runs only on snapshot load, which used to mean a node visited under a folder had no containment edge until the session was saved and reloaded. Anything reading containment live (a graph behavior’s watch, which names a region by its container) saw nothing there. Deriving at creation makes containment mean the same thing live and loaded.

The Domain half is deliberately not here. A domain anchor is the shallowest node on a host, so minting one node can re-anchor every other node sharing that host: a whole-graph fact, which stays with the whole-graph rebuild. This one is purely local, which is what makes it cheap enough to run per node.

Source

pub fn out_neighbors(&self, key: NodeKey) -> impl Iterator<Item = NodeKey> + '_

Iterate outgoing neighbor keys for a node

Source

pub fn in_neighbors(&self, key: NodeKey) -> impl Iterator<Item = NodeKey> + '_

Iterate incoming neighbor keys for a node

Source

pub fn neighbors_undirected( &self, key: NodeKey, ) -> impl Iterator<Item = NodeKey> + '_

Iterate undirected neighbor keys for a node.

Source

pub fn neighbors_undirected_sorted(&self, key: NodeKey) -> Vec<NodeKey> ⓘ

Undirected neighbors sorted by stable node-key order.

Source

pub fn connected_frame_import_nodes(&self, seeds: &[NodeKey]) -> Vec<NodeKey> ⓘ

Seed nodes plus one-hop undirected neighbors for frame import workflows.

Source

pub fn connected_candidates_with_depth( &self, source: NodeKey, max_depth: u8, ) -> Vec<(NodeKey, u8)>

Connected candidate expansion around a source node with depth annotations.

max_depth currently supports 1 or 2, matching connected-open scope behavior.

Source

pub fn hop_distances_from(&self, source: NodeKey) -> HashMap<NodeKey, usize>

Undirected hop distances from source using unit edge weights.

Source

pub fn orphan_node_keys(&self) -> Vec<NodeKey> ⓘ

Nodes with no incoming or outgoing edges.

Source

pub fn shortest_path(&self, from: NodeKey, to: NodeKey) -> Option<Vec<NodeKey>>

Shortest undirected path between two nodes using unit edge weights.

Source

pub fn is_reachable(&self, from: NodeKey, to: NodeKey) -> bool

Reachability in the undirected graph.

Source

pub fn weakly_connected_components(&self) -> Vec<Vec<NodeKey>>

Weakly connected components (undirected projection).

Source

pub fn component_members( &self, seed: Uuid, selectors: &[RelationSelector], ) -> Vec<Uuid>

The connected component of seed — it plus every node reachable through relations (undirected), breadth-first. Empty if seed is not in the graph. selectors is the edge projection: only edges matching a selector are followed (an empty slice follows every family). So the same nodes can be one Component under one projection and a different one under another. The Component graphlet’s derivation. (Graphlet derivation, Phase 3 — selectors.)

Source

pub fn ego_members( &self, seed: Uuid, radius: u8, selectors: &[RelationSelector], ) -> Vec<Uuid>

The Ego neighborhood of seed: itself plus every node within radius undirected hops, breadth-first (radius 0 = just the seed), over the selectors edge projection (empty = all families). The Ego graphlet’s derivation. (Graphlet derivation, Phase 3 — selectors.)

Source

pub fn strongly_connected_components(&self) -> Vec<Vec<NodeKey>>

Strongly connected components in the directed graph.

Source

pub fn has_edge_between(&self, from: NodeKey, to: NodeKey) -> bool

Check if a directed edge exists from from to to

Source

pub fn node_count(&self) -> usize

Count of nodes in the graph

Source

pub fn edge_count(&self) -> usize

Count of edges in the graph

Source§

impl Graph

Source

pub fn node_display_label(&self, key: NodeKey) -> String

A human-meaningful label for key’s node (see the module docs for the derivation). Empty string if the key is not in the graph. Full text, not width-clamped: a caller drawing into a fixed box truncates.

Source§

impl Graph

Source

pub fn from_snapshot(snapshot: &GraphSnapshot) -> Self

Source§

impl Graph

Source§

impl Graph

Source

pub fn new() -> Self

Create a new empty graph

Source

pub fn set_current_session(&mut self, session: u64)

Set the current app-launch session number (Alembic B5). The host calls this once, right after construction or snapshot-restore, with its persisted-and-incremented session counter; every navigate_node call afterwards stamps the visited node’s [Node::last_session_visited] with this value.

Source

pub fn revision(&self) -> u64

The current structural revision (see revision). A consumer captures it alongside a derived result and recomputes only when it has advanced. (Graph signals.)

Source

pub fn node_namespace_id(url: &str) -> Uuid

The deterministic node UUID for url: a name-based UUIDv5 under NODE_NAMESPACE. Two hosts that materialize the same url mint the same id, so a federated merge needs no identity reconciliation. The linked-data ingest layer uses this for a document’s @id, where the URL is the identity. Raw [add_node] keeps a fresh random id, because the kernel treats a node’s address as a property and lets several nodes share one (see get_nodes_by_url).

Source

pub fn node_can_back(&self, key: NodeKey) -> bool

Whether key’s within-node history can step back (toolbar gating).

Source

pub fn node_can_forward(&self, key: NodeKey) -> bool

Whether key’s within-node history can step forward (toolbar gating).

Source

pub fn node_current_url(&self, key: NodeKey) -> Option<String>

key’s current page (its history cursor’s URL), if any.

Source

pub fn node_history_projection(&self, key: NodeKey) -> NodeHistoryProjection

key’s linear-history projection (active path + cursor).

Source

pub fn node_history_branch_projection( &self, key: NodeKey, ) -> NodeHistoryBranchProjection

key’s branching-history projection (visit tree with alternates).

Source

pub fn node_history_semantic_summary( &self, key: NodeKey, ) -> NodeHistorySemanticSummary

A coarse semantic summary of key’s history.

Source

pub fn recent_visited(&self, limit: usize) -> Vec<RecentVisit>

The graph’s recently-visited nodes, newest first, capped at limit — the graph-wide “recent” projection over the shared visit space (gloss; the lineage pane). Delegates to SharedNavigationMemory::recent_visited.

Trait Implementations§

Source§

impl Archive for Graph

Source§

type Archived = <GraphSnapshot as Archive>::Archived

The archived representation of this type. Read more
Source§

type Resolver = <GraphSnapshot as Archive>::Resolver

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
Source§

fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)

Creates the archived version of this value at the given position and writes it to the given output. Read more
Source§

const COPY_OPTIMIZATION: CopyOptimization<Self> = _

An optimization flag that allows the bytes of this type to be copied directly to a writer instead of calling serialize. Read more
Source§

impl Clone for Graph

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Graph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<D> Deserialize<Graph, D> for Archived<GraphSnapshot>

Source§

fn deserialize(&self, deserializer: &mut D) -> Result<Graph, D::Error>

Deserializes using the given deserializer
Source§

impl<S> Serialize<S> for Graph

Source§

fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.

Auto Trait Implementations§

§

impl Freeze for Graph

§

impl RefUnwindSafe for Graph

§

impl Send for Graph

§

impl Sync for Graph

§

impl Unpin for Graph

§

impl UnsafeUnpin for Graph

§

impl UnwindSafe for Graph

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> ArchiveUnsized for T
where T: Archive,

Source§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
Source§

fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata

Creates the archived version of the metadata for this value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T, S> SerializeUnsized<S> for T
where T: Serialize<S>, S: Fallible + Writer + ?Sized,

Source§

fn serialize_unsized( &self, serializer: &mut S, ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.