pub struct MultiDiGraph<T, E>{ /* private fields */ }
Expand description
MultiDiGraph
is actually a generic
multi directed graph where each node of type T
and edge of type E
must implement: T: Ord + Clone + std::fmt::Display + std::fmt::Debug
and
E: Ord + Clone + std::fmt::Display + std::fmt::Debug
Implementations§
Source§impl<T, E> MultiDiGraph<T, E>
impl<T, E> MultiDiGraph<T, E>
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
7fn main() {
8 println!("Example of dot file creation. Check example2.dot file.\nTo create a picture install graphivz.\n\n$ dot -Tpng example2.dot -o example2.png\n\n");
9
10 let mut fd = File::create("example2.dot").expect("error creating file");
11 let mut graph = MultiDiGraph::<String, String>::new();
12 graph.add_node("a".to_string());
13 graph.add_node("b".to_string());
14 graph.add_node("c".to_string());
15 graph.add_node("d".to_string());
16 graph.add_edge("a".to_string(), "b".to_string(), "ab".to_string());
17 graph.add_edge("b".to_string(), "c".to_string(), "bc".to_string());
18 graph.add_edge("c".to_string(), "d".to_string(), "cd".to_string());
19 graph.add_edge("a".to_string(), "d".to_string(), "ad".to_string());
20 graph.to_dot_file(&mut fd, &String::from("to_dot_multidigraph_test"));
21 let s = graph.to_dot_string(&String::from("to_dot_multidigraph_test"));
22 println!("File content:\n{}", s);
23}
Trait Implementations§
Source§impl<T, E> Drop for MultiDiGraph<T, E>
impl<T, E> Drop for MultiDiGraph<T, E>
Source§impl<T, E> IGraph<T> for MultiDiGraph<T, E>
impl<T, E> IGraph<T> for MultiDiGraph<T, E>
Source§fn is_directly_connected(&self, from: T, to: T) -> bool
fn is_directly_connected(&self, from: T, to: T) -> bool
Returns if node to
is a neighbord of from
Source§fn is_connected(&self, from: T, to: T) -> bool
fn is_connected(&self, from: T, to: T) -> bool
Returns if a node from
is connected to a node to
Source§fn to_dot_file(&self, file: &mut File, graph_name: &str)
fn to_dot_file(&self, file: &mut File, graph_name: &str)
Exports the graph to a dot file. file
must be a valid
file ready to be written.
graph_name
is the name of the graph
Source§fn to_dot_string(&self, graph_name: &str) -> String
fn to_dot_string(&self, graph_name: &str) -> String
Returns an String
with a dot file representation of the graph
Source§fn node_exists(&self, from: T) -> bool
fn node_exists(&self, from: T) -> bool
true
if node node
existsSource§fn count_nodes(&self) -> usize
fn count_nodes(&self) -> usize
Source§impl<T, E> IMultiDiGraph<T, E> for MultiDiGraph<T, E>
impl<T, E> IMultiDiGraph<T, E> for MultiDiGraph<T, E>
Source§fn add_edge(&mut self, from: T, to: T, edge: E)
fn add_edge(&mut self, from: T, to: T, edge: E)
Creates a new edge from node from
to node to
nodes from
and to
must be previously added to the graph
Source§fn is_directly_connected_by(&self, from: T, to: T, edge: E) -> bool
fn is_directly_connected_by(&self, from: T, to: T, edge: E) -> bool
Returns if node to
is a neighbord of from
by edge edge
Source§fn all_simple_paths(&self, from: T, to: T) -> Vec<Vec<(T, T, E)>>
fn all_simple_paths(&self, from: T, to: T) -> Vec<Vec<(T, T, E)>>
Returns a vector Vec<Vec<(T, T, E)>>
containing all the simple paths
from node from
to node to
in a vector of tuples (from,to,edge)
Source§fn get_neighbors(&self, from: T) -> Vec<(T, E)>
fn get_neighbors(&self, from: T) -> Vec<(T, E)>
neighbors
of node from