Skip to main content

PathAnalyzer

Struct PathAnalyzer 

Source
pub struct PathAnalyzer;
Expand description

路径分析器

Implementations§

Source§

impl PathAnalyzer

Source

pub fn is_reachable(graph: &DirectedGraph, from: NodeId, to: NodeId) -> bool

检查从 fromto 是否可达

Source

pub fn find_all_paths( graph: &DirectedGraph, from: NodeId, to: NodeId, max_depth: usize, ) -> Vec<Vec<NodeId>>

查找从 fromto 的所有简单路径(限制最大长度)

简单路径:不重复访问节点。 max_depth 限制路径最大长度,防止指数爆炸。

Source

pub fn shortest_path_length( graph: &DirectedGraph, from: NodeId, to: NodeId, ) -> Option<usize>

计算从 fromto 的最短路径长度(BFS)

Source

pub fn bfs_distances( graph: &DirectedGraph, start: NodeId, ) -> HashMap<NodeId, usize>

计算从 start 到所有可达节点的最短距离

Source

pub fn reachable_nodes(graph: &DirectedGraph, start: NodeId) -> HashSet<NodeId>

查找从 start 可达的所有节点

Source

pub fn diameter(graph: &DirectedGraph) -> Option<usize>

计算图的直径(最长最短路径)

对于无权图,直径是所有节点对之间最短路径的最大值。

Source

pub fn eccentricity(graph: &DirectedGraph, node: NodeId) -> Option<usize>

计算节点偏心度(到最远可达节点的距离)

Source

pub fn radius(graph: &DirectedGraph) -> Option<usize>

计算图的半径(最小偏心度)

Auto Trait Implementations§

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> 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> 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, 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.