pub struct Graph {
pub nodes: HashMap<String, GraphNode>,
pub edges: Vec<GraphEdge>,
pub directed: bool,
}Expand description
Graph representation
Fields§
§nodes: HashMap<String, GraphNode>Nodes in the graph.
edges: Vec<GraphEdge>Edges in the graph.
directed: boolWhether the graph is directed.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn get_neighbors(&self, node_id: &str) -> Vec<&str>
pub fn get_neighbors(&self, node_id: &str) -> Vec<&str>
Gets the neighbors of a node.
Sourcepub fn get_degree(&self, node_id: &str) -> usize
pub fn get_degree(&self, node_id: &str) -> usize
Gets the degree of a node.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Checks if the graph is connected.
Sourcepub fn find_cycles(&self) -> Vec<Vec<String>>
pub fn find_cycles(&self) -> Vec<Vec<String>>
Finds all cycles in the graph.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
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