pub struct Graph { /* private fields */ }Expand description
Main graph structure backed by petgraph::StableGraph
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn table_stats(&self) -> GraphTableStats
pub fn table_stats(&self) -> GraphTableStats
Cheap live counts for the graph’s kernel-owned tables.
Source§impl Graph
impl Graph
Sourcepub fn copy_node_from(
&mut self,
source: &Node,
source_graph: Option<String>,
position: Point2D<f32>,
) -> NodeKey
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.
Sourcepub fn copy_node_from_with_id(
&mut self,
id: Uuid,
source: &Node,
source_graph: Option<String>,
_position: Point2D<f32>,
) -> NodeKey
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).
Sourcepub fn copy_node_from_xy(
&mut self,
source: &Node,
source_graph: Option<String>,
x: f32,
y: f32,
) -> NodeKey
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.)
Sourcepub fn copy_component_from(
&mut self,
source: &Graph,
seed: Uuid,
source_graph: Option<String>,
) -> ComponentCopy
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
impl Graph
pub fn import_records(&self) -> &[ImportRecord]
pub fn import_record_summaries_for_node( &self, key: NodeKey, ) -> Vec<NodeImportRecordSummary>
pub fn import_record_member_keys(&self, record_id: &str) -> Vec<NodeKey> ⓘ
Source§impl Graph
impl Graph
Sourcepub fn facets(&self) -> &NodeFacetStore
pub fn facets(&self) -> &NodeFacetStore
The graph’s single live atomic-facet authority.
Sourcepub fn facets_mut(&mut self) -> &mut NodeFacetStore
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.
Sourcepub fn overlay_facets(&mut self, facets: NodeFacetStore)
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
impl Graph
Sourcepub fn bear_nested(&mut self, key: NodeKey, nested: Option<LogId>) -> bool
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.
pub fn frame_layout_hints(&self, key: NodeKey) -> Option<Vec<FrameLayoutHint>>
pub fn frame_split_offer_suppressed(&self, key: NodeKey) -> Option<bool>
pub fn node_is_pinned(&self, key: NodeKey) -> Option<bool>
pub fn node_tag_presentation( &self, key: NodeKey, ) -> Option<NodeTagPresentationState>
pub fn node_import_provenance( &self, key: NodeKey, ) -> Option<Vec<NodeImportProvenance>>
pub fn node_classifications( &self, key: NodeKey, ) -> Option<Vec<NodeClassification>>
pub fn node_properties(&self, key: NodeKey) -> Option<Vec<NodeProperty>>
pub fn node_derivations(&self, key: NodeKey) -> Option<Vec<NodeDerivation>>
pub fn node_last_visited(&self, key: NodeKey) -> Option<SystemTime>
pub fn node_last_session_visited(&self, key: NodeKey) -> Option<u64>
Source§impl Graph
impl Graph
Sourcepub fn couplings(&self) -> impl Iterator<Item = &Coupling>
pub fn couplings(&self) -> impl Iterator<Item = &Coupling>
All couplings, in unspecified order.
Sourcepub fn couplings_for_field(
&self,
field: FieldId,
) -> impl Iterator<Item = &Coupling> + '_
pub fn couplings_for_field( &self, field: FieldId, ) -> impl Iterator<Item = &Coupling> + '_
Couplings whose target is the given field.
Sourcepub fn field_coupling_strength(&self, field: FieldId) -> Option<f32>
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.)
Sourcepub fn nodes_matching<'a>(
&'a self,
selector: &'a NodeSelector,
) -> impl Iterator<Item = NodeKey> + 'a
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
impl Graph
Sourcepub fn collect_node_traversals(
&self,
key: NodeKey,
) -> Option<Vec<DissolvedTraversalRecord>>
pub fn collect_node_traversals( &self, key: NodeKey, ) -> Option<Vec<DissolvedTraversalRecord>>
Collect traversals from all incident edges without mutating graph state.
Sourcepub fn assert_semantic_statement(
&mut self,
from: NodeKey,
to: NodeKey,
spec: SemanticStatementSpec,
) -> Option<(EdgeKey, StatementAssert)>
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.
Sourcepub fn assert_persisted_semantic_statement(
&mut self,
from: NodeKey,
to: NodeKey,
statement: SemanticStatement,
) -> Option<EdgeKey>
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.
Sourcepub fn retract_semantic_statement(
&mut self,
from: NodeKey,
to: NodeKey,
statement_id: &str,
) -> bool
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”.
Sourcepub fn get_edge(&self, key: EdgeKey) -> Option<&EdgePayload>
pub fn get_edge(&self, key: EdgeKey) -> Option<&EdgePayload>
Get an edge payload by key.
Source§impl Graph
impl Graph
Sourcepub fn find_node_by_address(
&self,
address: &Address,
) -> Option<(NodeKey, &Node)>
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).
Sourcepub fn get_node_by_url(&self, url: &str) -> Option<(NodeKey, &Node)>
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.
Sourcepub fn get_nodes_by_url(&self, url: &str) -> Vec<NodeKey> ⓘ
pub fn get_nodes_by_url(&self, url: &str) -> Vec<NodeKey> ⓘ
Get all node keys currently mapped to a URL.
Sourcepub fn get_node_key_by_id(&self, id: Uuid) -> Option<NodeKey>
pub fn get_node_key_by_id(&self, id: Uuid) -> Option<NodeKey>
Get node key by UUID.
Sourcepub fn nodes(&self) -> impl Iterator<Item = (NodeKey, &Node)>
pub fn nodes(&self) -> impl Iterator<Item = (NodeKey, &Node)>
Iterate over all nodes as (key, node) pairs
Sourcepub fn relations(&self) -> impl Iterator<Item = RelationView> + '_
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.
pub fn semantic_edges(&self) -> impl Iterator<Item = SemanticEdgeView> + '_
pub fn arrangement_edges( &self, ) -> impl Iterator<Item = ArrangementEdgeView> + '_
pub fn containment_edges( &self, ) -> impl Iterator<Item = ContainmentEdgeView> + '_
Sourcepub fn derive_containment_for(&mut self, key: NodeKey)
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.
Sourcepub fn out_neighbors(&self, key: NodeKey) -> impl Iterator<Item = NodeKey> + '_
pub fn out_neighbors(&self, key: NodeKey) -> impl Iterator<Item = NodeKey> + '_
Iterate outgoing neighbor keys for a node
Sourcepub fn in_neighbors(&self, key: NodeKey) -> impl Iterator<Item = NodeKey> + '_
pub fn in_neighbors(&self, key: NodeKey) -> impl Iterator<Item = NodeKey> + '_
Iterate incoming neighbor keys for a node
Sourcepub fn neighbors_undirected(
&self,
key: NodeKey,
) -> impl Iterator<Item = NodeKey> + '_
pub fn neighbors_undirected( &self, key: NodeKey, ) -> impl Iterator<Item = NodeKey> + '_
Iterate undirected neighbor keys for a node.
Sourcepub fn neighbors_undirected_sorted(&self, key: NodeKey) -> Vec<NodeKey> ⓘ
pub fn neighbors_undirected_sorted(&self, key: NodeKey) -> Vec<NodeKey> ⓘ
Undirected neighbors sorted by stable node-key order.
Sourcepub fn connected_frame_import_nodes(&self, seeds: &[NodeKey]) -> Vec<NodeKey> ⓘ
pub fn connected_frame_import_nodes(&self, seeds: &[NodeKey]) -> Vec<NodeKey> ⓘ
Seed nodes plus one-hop undirected neighbors for frame import workflows.
Sourcepub fn connected_candidates_with_depth(
&self,
source: NodeKey,
max_depth: u8,
) -> Vec<(NodeKey, u8)>
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.
Sourcepub fn hop_distances_from(&self, source: NodeKey) -> HashMap<NodeKey, usize>
pub fn hop_distances_from(&self, source: NodeKey) -> HashMap<NodeKey, usize>
Undirected hop distances from source using unit edge weights.
Sourcepub fn orphan_node_keys(&self) -> Vec<NodeKey> ⓘ
pub fn orphan_node_keys(&self) -> Vec<NodeKey> ⓘ
Nodes with no incoming or outgoing edges.
Sourcepub fn shortest_path(&self, from: NodeKey, to: NodeKey) -> Option<Vec<NodeKey>>
pub fn shortest_path(&self, from: NodeKey, to: NodeKey) -> Option<Vec<NodeKey>>
Shortest undirected path between two nodes using unit edge weights.
Sourcepub fn is_reachable(&self, from: NodeKey, to: NodeKey) -> bool
pub fn is_reachable(&self, from: NodeKey, to: NodeKey) -> bool
Reachability in the undirected graph.
Sourcepub fn weakly_connected_components(&self) -> Vec<Vec<NodeKey>>
pub fn weakly_connected_components(&self) -> Vec<Vec<NodeKey>>
Weakly connected components (undirected projection).
Sourcepub fn component_members(
&self,
seed: Uuid,
selectors: &[RelationSelector],
) -> Vec<Uuid>
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.)
Sourcepub fn ego_members(
&self,
seed: Uuid,
radius: u8,
selectors: &[RelationSelector],
) -> Vec<Uuid>
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.)
Sourcepub fn strongly_connected_components(&self) -> Vec<Vec<NodeKey>>
pub fn strongly_connected_components(&self) -> Vec<Vec<NodeKey>>
Strongly connected components in the directed graph.
Sourcepub fn has_edge_between(&self, from: NodeKey, to: NodeKey) -> bool
pub fn has_edge_between(&self, from: NodeKey, to: NodeKey) -> bool
Check if a directed edge exists from from to to
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Count of nodes in the graph
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Count of edges in the graph
Source§impl Graph
impl Graph
Sourcepub fn node_display_label(&self, key: NodeKey) -> String
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
impl Graph
pub fn from_snapshot(snapshot: &GraphSnapshot) -> Self
Source§impl Graph
impl Graph
pub fn to_snapshot(&self) -> GraphSnapshot
Source§impl Graph
impl Graph
Sourcepub fn set_current_session(&mut self, session: u64)
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.
Sourcepub fn revision(&self) -> u64
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.)
Sourcepub fn node_namespace_id(url: &str) -> Uuid
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).
Sourcepub fn node_can_back(&self, key: NodeKey) -> bool
pub fn node_can_back(&self, key: NodeKey) -> bool
Whether key’s within-node history can step back (toolbar gating).
Sourcepub fn node_can_forward(&self, key: NodeKey) -> bool
pub fn node_can_forward(&self, key: NodeKey) -> bool
Whether key’s within-node history can step forward (toolbar gating).
Sourcepub fn node_current_url(&self, key: NodeKey) -> Option<String>
pub fn node_current_url(&self, key: NodeKey) -> Option<String>
key’s current page (its history cursor’s URL), if any.
Sourcepub fn node_history_projection(&self, key: NodeKey) -> NodeHistoryProjection
pub fn node_history_projection(&self, key: NodeKey) -> NodeHistoryProjection
key’s linear-history projection (active path + cursor).
Sourcepub fn node_history_branch_projection(
&self,
key: NodeKey,
) -> NodeHistoryBranchProjection
pub fn node_history_branch_projection( &self, key: NodeKey, ) -> NodeHistoryBranchProjection
key’s branching-history projection (visit tree with alternates).
Sourcepub fn node_history_semantic_summary(
&self,
key: NodeKey,
) -> NodeHistorySemanticSummary
pub fn node_history_semantic_summary( &self, key: NodeKey, ) -> NodeHistorySemanticSummary
A coarse semantic summary of key’s history.
Sourcepub fn recent_visited(&self, limit: usize) -> Vec<RecentVisit>
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
impl Archive for Graph
Source§type Archived = <GraphSnapshot as Archive>::Archived
type Archived = <GraphSnapshot as Archive>::Archived
Source§type Resolver = <GraphSnapshot as Archive>::Resolver
type Resolver = <GraphSnapshot as Archive>::Resolver
Source§fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
Source§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize. Read moreSource§impl<D> Deserialize<Graph, D> for Archived<GraphSnapshot>
impl<D> Deserialize<Graph, D> for Archived<GraphSnapshot>
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> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.