pub struct Graph<L: Hash, T, E = (), M: MulTE<T, E> = MulTEDefaultType> {
pub edges: Vec<Edge<T, E>>,
/* private fields */
}
Expand description
存储图的数据结构
其中L为点的标签(label)的类型
T为边的容量的类型
E为边的费用的类型
M用于实现容量和费用的相乘
Fields§
§edges: Vec<Edge<T, E>>
Implementations§
Source§impl<L, T, E, M> Graph<L, T, E, M>
impl<L, T, E, M> Graph<L, T, E, M>
Sourcepub fn init_graph(&mut self)
pub fn init_graph(&mut self)
初始化一个图, 将原有的边和点全部去除
Sourcepub fn create_graph(nodes: &[L]) -> Self
pub fn create_graph(nodes: &[L]) -> Self
使用一些点的标签来创建一个图,按照在vector中的顺序赋予其编号
Sourcepub fn first_edge(&self, index: usize) -> Option<&Edge<T, E>>
pub fn first_edge(&self, index: usize) -> Option<&Edge<T, E>>
获得从index指出的第一条边
Sourcepub fn next_edge(&self, now: &Edge<T, E>) -> Option<&Edge<T, E>>
pub fn next_edge(&self, now: &Edge<T, E>) -> Option<&Edge<T, E>>
获得和now从同一个点指出的下一条边
配合first_edge可以这样使用:
use network_flow::graph::Graph;
let mut g = Graph::<usize, i32>::new();
// build graph
let mut temp = g.first_edge(0);
while let Some(edge) = temp {
// do something
temp = g.next_edge(edge);
}
Sourcepub fn get_all_edges(&self, index: usize) -> Vec<(&Edge<T, E>, usize)>
pub fn get_all_edges(&self, index: usize) -> Vec<(&Edge<T, E>, usize)>
使用first_edge和next_edge函数得到从index出发的所有边及其编号
Sourcepub fn get_neighbor(&self, index: usize) -> Vec<usize>
pub fn get_neighbor(&self, index: usize) -> Vec<usize>
获得与index相邻的所有点
Trait Implementations§
Auto Trait Implementations§
impl<L, T, E, M> Freeze for Graph<L, T, E, M>
impl<L, T, E, M> RefUnwindSafe for Graph<L, T, E, M>
impl<L, T, E, M> Send for Graph<L, T, E, M>
impl<L, T, E, M> Sync for Graph<L, T, E, M>
impl<L, T, E, M> Unpin for Graph<L, T, E, M>
impl<L, T, E, M> UnwindSafe for Graph<L, T, E, M>
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