pub struct Graph<GL, N, E>where
GL: Default,{ /* private fields */ }
Implementations§
Source§impl<GL: Default, N: Default + Clone + Debug, E: Default + Clone + Debug> Graph<GL, N, E>
impl<GL: Default, N: Default + Clone + Debug, E: Default + Clone + Debug> Graph<GL, N, E>
pub fn new(opts: Option<GraphOption>) -> Self
Sourcepub fn is_directed(&self) -> bool
pub fn is_directed(&self) -> bool
Whether graph was created with ‘directed’ flag set to true or not.
Sourcepub fn is_multigraph(&self) -> bool
pub fn is_multigraph(&self) -> bool
Whether graph was created with ‘multigraph’ flag set to true or not.
Sourcepub fn is_compound(&self) -> bool
pub fn is_compound(&self) -> bool
Whether graph was created with ‘compound’ flag set to true or not.
Sourcepub fn set_default_node_label(
&mut self,
new_default: DefaultNodeLabel<N>,
) -> &mut Self
pub fn set_default_node_label( &mut self, new_default: DefaultNodeLabel<N>, ) -> &mut Self
Sets the default node label. If newDefault is a function, it will be invoked ach time when setting a label for a node. Otherwise, this label will be assigned as default label in case if no label was specified while setting a node. Complexity: O(1).
pub fn default_node_label(&self, node_id: String) -> N
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Gets the number of nodes in the graph. Complexity: O(1).
Sourcepub fn nodes(&self) -> Vec<String>
pub fn nodes(&self) -> Vec<String>
Gets all nodes of the graph. Note, the in case of compound graph subnodes are not included in list. Complexity: O(1).
Sourcepub fn set_nodes(
&mut self,
node_ids: Vec<String>,
value: Option<N>,
) -> &mut Self
pub fn set_nodes( &mut self, node_ids: Vec<String>, value: Option<N>, ) -> &mut Self
Invokes setNode method for each node in names list. Complexity: O(|names|).
Sourcepub fn set_node(&mut self, v: String, value: Option<N>) -> &mut Self
pub fn set_node(&mut self, v: String, value: Option<N>) -> &mut Self
Creates or updates the value for the node v in the graph. If label is supplied it is set as the value for the node. If label is not supplied and the node was created by this call then the default node label will be assigned. Complexity: O(1).
Sourcepub fn node(&self, v: &String) -> Option<&N>
pub fn node(&self, v: &String) -> Option<&N>
Gets the label of node with specified name. Complexity: O(|V|).
Sourcepub fn node_mut(&mut self, v: &String) -> Option<&mut N>
pub fn node_mut(&mut self, v: &String) -> Option<&mut N>
Gets the label of node with specified name. Complexity: O(|V|).
Sourcepub fn has_node(&self, v: &String) -> bool
pub fn has_node(&self, v: &String) -> bool
Detects whether graph has a node with specified name or not.
Sourcepub fn remove_node(&mut self, v: &String) -> &mut Self
pub fn remove_node(&mut self, v: &String) -> &mut Self
Remove the node with the name from the graph or do nothing if the node is not in the graph. If the node was removed this function also removes any incident edges. Complexity: O(1).
Sourcepub fn set_parent(
&mut self,
v: &String,
parent: Option<String>,
) -> Result<&mut Self, Box<dyn Error>>
pub fn set_parent( &mut self, v: &String, parent: Option<String>, ) -> Result<&mut Self, Box<dyn Error>>
Sets node p as a parent for node v if it is defined, or removes the parent for v if p is undefined. Method throws an exception in case of invoking it in context of noncompound graph. Average-case complexity: O(1).
pub fn _remove_from_parents_child_list(&mut self, v: &String)
Sourcepub fn parent(&self, v: &String) -> Option<&String>
pub fn parent(&self, v: &String) -> Option<&String>
Gets parent node for node v. Complexity: O(1).
Sourcepub fn children(&self, v: &String) -> Vec<String>
pub fn children(&self, v: &String) -> Vec<String>
Gets list of direct children of node v. Complexity: O(1).
Sourcepub fn predecessors(&self, v: &String) -> Option<Vec<String>>
pub fn predecessors(&self, v: &String) -> Option<Vec<String>>
Return all nodes that are predecessors of the specified node or undefined if node v is not in the graph. Behavior is undefined for undirected graphs - use neighbors instead. Complexity: O(|V|).
Sourcepub fn successors(&self, v: &String) -> Option<Vec<String>>
pub fn successors(&self, v: &String) -> Option<Vec<String>>
Return all nodes that are successors of the specified node or undefined if node v is not in the graph. Behavior is undefined for undirected graphs - use neighbors instead. Complexity: O(|V|).
Sourcepub fn neighbors(&self, v: &String) -> Option<Vec<String>>
pub fn neighbors(&self, v: &String) -> Option<Vec<String>>
Return all nodes that are predecessors or successors of the specified node or undefined if node v is not in the graph. Complexity: O(|V|).
pub fn is_leaf(&self, v: &String) -> bool
Sourcepub fn filter_nodes<F>(&self, filter: F) -> Self
pub fn filter_nodes<F>(&self, filter: F) -> Self
Creates new graph with nodes filtered via filter. Edges incident to rejected node are also removed. In case of compound graph, if parent is rejected by filter, than all its children are rejected too. Average-case complexity: O(|E|+|V|).
Sourcepub fn set_default_edge_label(
&mut self,
new_default: DefaultEdgeLabel<E>,
) -> &mut Self
pub fn set_default_edge_label( &mut self, new_default: DefaultEdgeLabel<E>, ) -> &mut Self
Sets the default edge label or factory function. This label will be assigned as default label in case if no label was specified while setting an edge or this function will be invoked each time when setting an edge with no label specified and returned value * will be used as a label for edge. Complexity: O(1).
pub fn default_edge_label(&self, edge_id: String) -> E
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Gets the number of edges in the graph. Complexity: O(1).
Sourcepub fn edges(&self) -> Vec<Edge>
pub fn edges(&self) -> Vec<Edge>
Gets edges of the graph. In case of compound graph subgraphs are not considered. Complexity: O(|E|).
Sourcepub fn set_path(&mut self, vs: &Vec<String>, value: Option<E>)
pub fn set_path(&mut self, vs: &Vec<String>, value: Option<E>)
Establish an edges path over the nodes in nodes list. If some edge is already exists, it will update its label, otherwise it will create an edge between pair of nodes with label provided or default label if no label provided. Complexity: O(|nodes|).
Sourcepub fn set_edge(
&mut self,
v: &String,
w: &String,
edge_label: Option<E>,
name: Option<String>,
) -> Result<&mut Self, Box<dyn Error>>
pub fn set_edge( &mut self, v: &String, w: &String, edge_label: Option<E>, name: Option<String>, ) -> Result<&mut Self, Box<dyn Error>>
Creates or updates the label for the edge (v, w) with the optionally supplied name. If label is supplied it is set as the value for the edge. If label is not supplied and the edge was created by this call then the default edge label will be assigned. The name parameter is only useful with multigraphs.
pub fn set_edge_with_obj( &mut self, e: &Edge, edge_label: Option<E>, ) -> Result<&mut Self, Box<dyn Error>>
Sourcepub fn edge(&self, v: &String, w: &String, name: Option<String>) -> Option<&E>
pub fn edge(&self, v: &String, w: &String, name: Option<String>) -> Option<&E>
Gets the label for the specified edge. Complexity: O(1).
Sourcepub fn edge_with_obj(&self, edge: &Edge) -> Option<&E>
pub fn edge_with_obj(&self, edge: &Edge) -> Option<&E>
Gets the label for the specified edge. Complexity: O(1).
Sourcepub fn edge_mut(
&mut self,
v: &String,
w: &String,
name: Option<String>,
) -> Option<&mut E>
pub fn edge_mut( &mut self, v: &String, w: &String, name: Option<String>, ) -> Option<&mut E>
Gets the label for the specified edge. Complexity: O(1).
Sourcepub fn edge_mut_with_obj(&mut self, edge: &Edge) -> Option<&mut E>
pub fn edge_mut_with_obj(&mut self, edge: &Edge) -> Option<&mut E>
Gets the label for the specified edge. Complexity: O(1).
Sourcepub fn has_edge(&self, v: &String, w: &String, name: Option<String>) -> bool
pub fn has_edge(&self, v: &String, w: &String, name: Option<String>) -> bool
Detects whether the graph contains specified edge or not. No subgraphs are considered. Complexity: O(1).
pub fn has_edge_with_obj(&self, edge: &Edge) -> bool
Sourcepub fn remove_edge(
&mut self,
v: &String,
w: &String,
name: Option<String>,
) -> &mut Self
pub fn remove_edge( &mut self, v: &String, w: &String, name: Option<String>, ) -> &mut Self
Removes the specified edge from the graph. No subgraphs are considered. Complexity: O(1).
Sourcepub fn remove_edge_with_obj(&mut self, e: &Edge) -> &mut Self
pub fn remove_edge_with_obj(&mut self, e: &Edge) -> &mut Self
Removes the specified edge from the graph. No subgraphs are considered. Complexity: O(1).
Sourcepub fn in_edges(&self, v: &String, u: Option<String>) -> Option<Vec<Edge>>
pub fn in_edges(&self, v: &String, u: Option<String>) -> Option<Vec<Edge>>
Return all edges that point to the node v. Optionally filters those edges down to just those coming from node u. Behavior is undefined for undirected graphs - use nodeEdges instead. Complexity: O(|E|).