pub struct Graph<N, E> {
pub kind: GraphKind,
/* private fields */
}Fields§
§kind: GraphKindImplementations§
Source§impl<N, E> Graph<N, E>
impl<N, E> Graph<N, E>
pub fn new(kind: GraphKind) -> Self
pub fn add_node(&mut self, data: N) -> NodeId
pub fn add_node_with_pos(&mut self, data: N, position: Vec2) -> NodeId
pub fn add_edge(&mut self, from: NodeId, to: NodeId, data: E) -> EdgeId
pub fn add_edge_weighted( &mut self, from: NodeId, to: NodeId, data: E, weight: f32, ) -> EdgeId
pub fn remove_node(&mut self, id: NodeId)
pub fn remove_edge(&mut self, id: EdgeId)
pub fn neighbors(&self, id: NodeId) -> Vec<NodeId>
pub fn neighbor_edges(&self, id: NodeId) -> Vec<(NodeId, EdgeId)>
pub fn degree(&self, id: NodeId) -> usize
pub fn node_count(&self) -> usize
pub fn edge_count(&self) -> usize
pub fn has_node(&self, id: NodeId) -> bool
pub fn has_edge(&self, id: EdgeId) -> bool
pub fn get_node(&self, id: NodeId) -> Option<&NodeData<N>>
pub fn get_node_mut(&mut self, id: NodeId) -> Option<&mut NodeData<N>>
pub fn get_edge(&self, id: EdgeId) -> Option<&EdgeData<E>>
pub fn get_edge_mut(&mut self, id: EdgeId) -> Option<&mut EdgeData<E>>
pub fn find_edge(&self, from: NodeId, to: NodeId) -> Option<EdgeId>
pub fn edge_weight(&self, id: EdgeId) -> f32
pub fn set_node_position(&mut self, id: NodeId, pos: Vec2)
pub fn node_position(&self, id: NodeId) -> Vec2
pub fn nodes(&self) -> impl Iterator<Item = &NodeData<N>>
pub fn node_ids(&self) -> Vec<NodeId>
pub fn edges(&self) -> impl Iterator<Item = &EdgeData<E>>
pub fn edge_ids(&self) -> Vec<EdgeId>
pub fn bfs(&self, start: NodeId) -> BfsIterator<'_, N, E> ⓘ
pub fn dfs(&self, start: NodeId) -> DfsIterator<'_, N, E> ⓘ
Sourcepub fn subgraph(&self, node_ids: &[NodeId]) -> Graph<N, E>
pub fn subgraph(&self, node_ids: &[NodeId]) -> Graph<N, E>
Extract a subgraph containing only the given node IDs
Source§impl<N: Clone, E: Clone> Graph<N, E>
impl<N: Clone, E: Clone> Graph<N, E>
pub fn to_adjacency_matrix(&self) -> AdjacencyMatrix
pub fn to_edge_list(&self) -> EdgeList
Trait Implementations§
Auto Trait Implementations§
impl<N, E> Freeze for Graph<N, E>
impl<N, E> RefUnwindSafe for Graph<N, E>where
N: RefUnwindSafe,
E: RefUnwindSafe,
impl<N, E> Send for Graph<N, E>
impl<N, E> Sync for Graph<N, E>
impl<N, E> Unpin for Graph<N, E>
impl<N, E> UnsafeUnpin for Graph<N, E>
impl<N, E> UnwindSafe for Graph<N, E>where
N: UnwindSafe,
E: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<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>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> 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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.