[−][src]Struct generic_graph::adjacency_list::elements::CompoundKey
The CompoundKey type is the type designated as edge key. It consist of two generic keys of the same type, representing the key of two adjacent Vertexes.
For two CompoundKey to be equal, the corresponding vertex key of the two must be equal as well. If two CompoundKey contain the same vertex key, but in different order they are not considered equal
This type can be constructed only via the generate_key()
function associated to the type DirectedEdge
Trait Implementations
impl<K: Clone + Hash + Eq> Clone for CompoundKey<K>
[src]
fn clone(&self) -> CompoundKey<K>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<K: Debug + Hash + Eq + Clone> Debug for CompoundKey<K>
[src]
impl<K: Hash + Eq + Clone, V, W: Add + Sub + Eq + Ord + Copy> DirectedGraph<SimpleVertex<K, V>, DirectedEdge<K, W>, K, V, W, CompoundKey<K>> for AdjacencyGraph<K, V, W>
[src]
AdjacencyGraph
implement the DirectedGraph trait Specifying the vertex type (DirectedVertex),
the edge type (Directed Edge), and the edge key type (CompoundKey). But the vertex key type,
the vertex value type and the edge weight type remain generics.
fn adjacent(&self, from: &K, to: &K) -> bool
[src]
Check if an edge going from the first to the second vertex exists
fn neighbors(&self, from: &K) -> Vec<&K>
[src]
Returns a Vector containing the keys of the vertexes reached by edges leaving from the vertex identified by the passed key
fn leading_to(&self, to: &K) -> Vec<&K>
[src]
Returns a vector containing the keys of the Vertexes from which an edge leave to reach the vertex identified by the passed key
fn get_vertex(&self, key: &K) -> Option<&SimpleVertex<K, V>>
[src]
Returns a reference to the vertex identified by the passed key
fn get_mut_vertex(&mut self, key: &K) -> Option<&mut SimpleVertex<K, V>>
[src]
Returns a mutable reference to the vertex identified by the passed key
fn get_edge(&self, pair: (&K, &K)) -> Option<&DirectedEdge<K, W>>
[src]
Returns a reference to the edge identified by the passed pair of keys
fn get_mut_edge(&mut self, pair: (&K, &K)) -> Option<&mut DirectedEdge<K, W>>
[src]
Returns a mutable reference to the edge identified by the passed pair of keys
impl<K: Hash + Eq + Clone, W: Add + Sub + Eq + Ord + Copy> Edge<K, W, CompoundKey<K>> for DirectedEdge<K, W>
[src]
DirectedEdge
implement the Edge trait Specifying the edge key type (CompoundKey). But the vertex key type
and the edge weight type remain generics.
fn get_weight(&self) -> W
[src]
Returns a copy of the weight (the weight type is required to implement Copy)
fn set_weight(&mut self, weight: W)
[src]
change the value of weight
fn left(&self) -> &K
[src]
Returns a reference to the key of the left hand vertex
fn right(&self) -> &K
[src]
Returns a reference to the key of the right hand vertex
fn get_pair(&self) -> (&K, &K)
[src]
Returns a pair of reference to the vertex keys. Ordered from left to right
fn generate_key(pair: (&K, &K)) -> CompoundKey<K>
[src]
Returns a new instance of CompoundKey from a pair of reference to vertex keys
Example
use generic_graph::adjacency_list::elements::DirectedEdge; use generic_graph::Edge; let edge = DirectedEdge::new(1, 2, 3); let key = DirectedEdge::<i32, i32>::generate_key(edge.get_pair()); assert_eq!(key, edge.key());
fn key(&self) -> CompoundKey<K>
[src]
Returns an new instance of CompoundKey generated from the pair of keys stored isn the edge
Example
use generic_graph::adjacency_list::elements::DirectedEdge; use generic_graph::Edge; let edge = DirectedEdge::new(1, 2, 3); let key = DirectedEdge::<i32, i32>::generate_key(edge.get_pair()); assert_eq!(key, edge.key());
impl<K: Eq + Hash + Clone> Eq for CompoundKey<K>
[src]
impl<K: Hash + Eq + Clone> Hash for CompoundKey<K>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<K: PartialEq + Hash + Eq + Clone> PartialEq<CompoundKey<K>> for CompoundKey<K>
[src]
fn eq(&self, other: &CompoundKey<K>) -> bool
[src]
fn ne(&self, other: &CompoundKey<K>) -> bool
[src]
impl<K: Hash + Eq + Clone> StructuralEq for CompoundKey<K>
[src]
impl<K: Hash + Eq + Clone> StructuralPartialEq for CompoundKey<K>
[src]
impl<K: Hash + Eq + Clone, V, W: Add + Sub + Eq + Ord + Copy> VariableEdges<SimpleVertex<K, V>, DirectedEdge<K, W>, K, V, W, CompoundKey<K>> for AdjacencyGraph<K, V, W>
[src]
AdjacencyGraph
uses HashMaps to store edges, allowing fast insertion and removal of the latter
fn add_edge(
&mut self,
edge: DirectedEdge<K, W>
) -> Result<Option<DirectedEdge<K, W>>, EdgeSide>
[src]
&mut self,
edge: DirectedEdge<K, W>
) -> Result<Option<DirectedEdge<K, W>>, EdgeSide>
The add_edge()
method shall return Ok(None)
if the element was not previously set. Otherwise the element shall be updated (but no the key)
and the old element shall be returned as Ok(Some(old_element))
. If one or both of the concerned vertexes are missing an error
containing an enum specifying which side is missing (Err(EdgeSide)
)
Examples
use generic_graph::adjacency_list::AdjacencyGraph; use generic_graph::{SimpleVertex, VariableVertexes, VariableEdges}; use generic_graph::adjacency_list::elements::DirectedEdge; use generic_graph::EdgeSide::Right; let mut graph = AdjacencyGraph::new(); graph.add_vertex(SimpleVertex::new(1, "a")); graph.add_vertex(SimpleVertex::new(2, "b")); graph.add_vertex(SimpleVertex::new(3, "c")); assert_eq!(Ok(None), graph.add_edge(DirectedEdge::new(1, 2, 0))); assert_eq!(Ok(None), graph.add_edge(DirectedEdge::new(2, 1, 0))); assert_eq!(Ok(None), graph.add_edge(DirectedEdge::new(3, 2, 0))); assert_eq!( Ok(Some(DirectedEdge::new(1, 2, 0))), graph.add_edge(DirectedEdge::new(1, 2, 3)) ); assert_eq!(Err(Right), graph.add_edge(DirectedEdge::new(1, 4, 0)));
fn remove_edge(&mut self, pair: (&K, &K)) -> Option<DirectedEdge<K, W>>
[src]
The remove_edge()
method shall return None
if the element was not found, or Some(element)
if it was found and removed.
Examples
use generic_graph::adjacency_list::AdjacencyGraph; use generic_graph::{SimpleVertex, VariableVertexes, VariableEdges}; use generic_graph::adjacency_list::elements::DirectedEdge; use generic_graph::EdgeSide::Right; let mut graph = AdjacencyGraph::new(); graph.add_vertex(SimpleVertex::new(1, "a")); graph.add_vertex(SimpleVertex::new(2, "b")); graph.add_edge(DirectedEdge::new(1, 2, 3)); assert_eq!( Some(DirectedEdge::new(1, 2, 3)), graph.remove_edge((&1, &2)) ); assert_eq!(None, graph.remove_edge((&1, &2)));
impl<K: Hash + Eq + Clone, V, W: Add + Sub + Eq + Ord + Copy> VariableVertexes<SimpleVertex<K, V>, DirectedEdge<K, W>, K, V, W, CompoundKey<K>> for AdjacencyGraph<K, V, W>
[src]
AdjacencyGraph
uses HashMaps to store vertexes, allowing fast insertion and removal of the latter
fn add_vertex(
&mut self,
vertex: SimpleVertex<K, V>
) -> Option<SimpleVertex<K, V>>
[src]
&mut self,
vertex: SimpleVertex<K, V>
) -> Option<SimpleVertex<K, V>>
This method adds (or, if present, updates maintaining its edges) a vertex and returns None ore Some(old_vertex)
Examples
use generic_graph::adjacency_list::AdjacencyGraph; use generic_graph::{SimpleVertex, VariableVertexes}; let mut graph = AdjacencyGraph::<i32, &str, i32>::new(); assert_eq!(None, graph.add_vertex(SimpleVertex::new(1, "a"))); assert_eq!(None, graph.add_vertex(SimpleVertex::new(2, "b"))); assert_eq!(Some(SimpleVertex::new(1, "a")), graph.add_vertex(SimpleVertex::new(1, "c")))
fn remove_vertex(&mut self, key: K) -> Option<SimpleVertex<K, V>>
[src]
This method removes a vertex and its edges from the graph and returns None ore Some(old_vertex)
Examples
use generic_graph::adjacency_list::AdjacencyGraph; use generic_graph::{SimpleVertex, VariableVertexes}; let mut graph = AdjacencyGraph::<i32, &str, i32>::new(); graph.add_vertex(SimpleVertex::new(1, "a")); graph.add_vertex(SimpleVertex::new(2, "b")); assert_eq!(None, graph.remove_vertex(0)); assert_eq!(Some(SimpleVertex::new(1, "a")), graph.remove_vertex(1)); assert_eq!(Some(SimpleVertex::new(2, "b")), graph.remove_vertex(2)); assert_eq!(None, graph.remove_vertex(1));
Auto Trait Implementations
impl<K> RefUnwindSafe for CompoundKey<K> where
K: RefUnwindSafe,
K: RefUnwindSafe,
impl<K> Send for CompoundKey<K> where
K: Send,
K: Send,
impl<K> Sync for CompoundKey<K> where
K: Sync,
K: Sync,
impl<K> Unpin for CompoundKey<K> where
K: Unpin,
K: Unpin,
impl<K> UnwindSafe for CompoundKey<K> where
K: UnwindSafe,
K: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,