pub struct Graph {
pub nodes: Vec<Node>,
pub edges: Vec<Edge>,
/* private fields */
}Expand description
The typed, bidirectional document multigraph.
Fields§
§nodes: Vec<Node>Nodes in input (document discovery) order.
edges: Vec<Edge>Edges in declaration order.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn build(docs: &[&StrayMarkDocument]) -> Graph
pub fn build(docs: &[&StrayMarkDocument]) -> Graph
Build the graph from parsed documents. Never drops a node or an edge:
orphan documents become isolated nodes; references to ids absent from
the corpus become resolved: false edges.
Sourcepub fn out_edges(&self, id: &str) -> impl Iterator<Item = &Edge>
pub fn out_edges(&self, id: &str) -> impl Iterator<Item = &Edge>
Outgoing edges of a node, in declaration order.
Sourcepub fn in_edges(&self, id: &str) -> impl Iterator<Item = &Edge>
pub fn in_edges(&self, id: &str) -> impl Iterator<Item = &Edge>
Incoming (resolved) edges of a node.
Sourcepub fn orphans(&self) -> impl Iterator<Item = &Node>
pub fn orphans(&self) -> impl Iterator<Item = &Node>
Documents with no links in either direction, in input order.
Sourcepub fn dangling_edges(&self) -> impl Iterator<Item = &Edge>
pub fn dangling_edges(&self) -> impl Iterator<Item = &Edge>
Edges whose target id is absent from the corpus, in declaration order.
Sourcepub fn thread(&self, id: &str, depth: Option<usize>) -> Option<Thread>
pub fn thread(&self, id: &str, depth: Option<usize>) -> Option<Thread>
The thread of a node (Spec 001 §3.3, story S2): “everything it links
to and everything that links to it, transitively” — its transitive
descendants (following out-edges) plus its transitive ancestors
(following in-edges), optionally bounded by depth per direction.
Deliberately NOT the undirected connected component: that would also pull in “siblings” (documents merely co-citing a shared neighbor), and in tightly-linked corpora it degenerates into highlighting everything. The thread is the node’s line of reasoning, not its neighborhood.
Returns the node ids and edge indices (into Graph::edges) to
highlight. The edge set is every edge whose endpoints both belong to
the thread, plus the dangling out-edges of thread members.