pub struct Graph {
pub name: String,
pub nodes: Vec<Node>,
pub edges: Vec<Edge>,
}
Expand description
Graph represents a directed graph as a list of nodes and list of edges.
Fields§
§name: String
Identifier for the graph
nodes: Vec<Node>
The Vector containing the Nodes
edges: Vec<Edge>
The Vector containing the Edges
Implementations§
Source§impl Graph
impl Graph
pub fn new(name: String, nodes: Vec<Node>, edges: Vec<Edge>) -> Graph
Sourcepub fn adj_list(&self) -> AdjList<'_>
pub fn adj_list(&self) -> AdjList<'_>
Returns the adjacency list representation of the graph. Adjacency list can be used to easily find the childern of a given node. If the a node does not have any childern, then the list correspoding to that node will be empty.
Sourcepub fn rev_adj_list(&self) -> AdjList<'_>
pub fn rev_adj_list(&self) -> AdjList<'_>
Returns the reverse adjacency list representation of the graph. Reverse adjacency list represents the adjacency list of a directed graph where the edges have been reversed. Reverse adjacency list can be used to easily find the parents of a given node. If the a node does not have any childern, then the list correspoding to that node will be empty.
Sourcepub fn get_node_by_label(&self, label: &str) -> Option<&Node>
pub fn get_node_by_label(&self, label: &str) -> Option<&Node>
Returns the node with the given label, if found.