pub struct GraphView { /* private fields */ }Expand description
从 relations 构建的内存态图。节点权重 = 实体 record_id,边权重 = 谓词文本。
图是有向的(petgraph Graph 默认 Directed,neighbors 只返回出边):
反向查询(如由「父亲」反查「子女」)不会自动连通,靠 predicate_rules 在 snapshot
里补出对称/逆关系的虚拟边来打通,物理表不落双向边。
节点 id 是缩点后的代表 id:互为 sys:same_as 的实体被并查集折叠成同一节点,
canonical 保存「原始 id -> 代表 id」的映射,查询入口先做一次换算。
Implementations§
Source§impl GraphView
impl GraphView
pub fn node_count(&self) -> usize
pub fn edge_count(&self) -> usize
Sourcepub fn ego_ids(&self, root: i64, depth: usize, limit: usize) -> Vec<i64>
pub fn ego_ids(&self, root: i64, depth: usize, limit: usize) -> Vec<i64>
从 root 出发 depth 跳内的实体 id(不含 root)。root 会先折算成缩点后的代表 id。
Sourcepub fn path_ids(&self, from: i64, to: i64) -> Option<Vec<i64>>
pub fn path_ids(&self, from: i64, to: i64) -> Option<Vec<i64>>
from 到 to 的最短路径(节点 id 列表,含两端)。用 petgraph 的 astar。
两端会先折算成缩点后的代表 id。
Sourcepub fn component_count(&self) -> usize
pub fn component_count(&self) -> usize
连通分量数量(无向)。用 petgraph 的 connected_components。
Auto Trait Implementations§
impl Freeze for GraphView
impl RefUnwindSafe for GraphView
impl Send for GraphView
impl Sync for GraphView
impl Unpin for GraphView
impl UnsafeUnpin for GraphView
impl UnwindSafe for GraphView
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more