Struct MultiDiGraph

Source
pub struct MultiDiGraph<T, E>
where T: Ord + Clone + Display + Debug, E: Ord + Clone + Display + Debug,
{ /* 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>
where T: Ord + Clone + Display + Debug, E: Ord + Clone + Display + Debug,

Source

pub fn new() -> Self

Examples found in repository?
examples/example2.rs (line 11)
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>
where T: Ord + Clone + Display + Debug, E: Ord + Clone + Display + Debug,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T, E> IGraph<T> for MultiDiGraph<T, E>
where T: Ord + Clone + Display + Debug, E: Ord + Clone + Display + Debug,

Source§

fn add_node(&mut self, elem: T)

Adds a new node elem to the graph

Source§

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

Returns if a node from is connected to a node to

Source§

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

Returns an String with a dot file representation of the graph

Source§

fn node_exists(&self, from: T) -> bool

Returns true if node node exists
Source§

fn is_empty(&self) -> bool

Returns if a graph doesn’t contain nodes
Source§

fn count_nodes(&self) -> usize

Returns how many nodes are in the graph
Source§

fn get_nodes(&self) -> Vec<T>

Returns a vector of the elements
Source§

impl<T, E> IMultiDiGraph<T, E> for MultiDiGraph<T, E>
where T: Ord + Clone + Display + Debug, E: Ord + Clone + Display + Debug,

Source§

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

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)>>

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)>

Returns a vector containing the neighbors of node from

Auto Trait Implementations§

§

impl<T, E> !Freeze for MultiDiGraph<T, E>

§

impl<T, E> !RefUnwindSafe for MultiDiGraph<T, E>

§

impl<T, E> !Send for MultiDiGraph<T, E>

§

impl<T, E> !Sync for MultiDiGraph<T, E>

§

impl<T, E> Unpin for MultiDiGraph<T, E>

§

impl<T, E> !UnwindSafe for MultiDiGraph<T, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.