pub trait Graph: Sized + Debug {
type Vertex: Debug + Element;
type Edge: Debug + Element;
type VertexId: Debug + Eq + PartialEq + Copy + Clone + Hash + Into<ElementId<Self>> + 'static;
type EdgeId: Debug + Eq + PartialEq + Copy + Clone + Hash + Into<ElementId<Self>> + 'static;
type VertexReference<'graph>: VertexReference<'graph, Self>
where Self: 'graph;
type VertexReferenceMut<'graph>: VertexReferenceMut<'graph, Self>
where Self: 'graph;
type EdgeReference<'graph>: EdgeReference<'graph, Self>
where Self: 'graph;
type EdgeReferenceMut<'graph>: EdgeReferenceMut<'graph, Self>
where Self: 'graph;
type EdgeIter<'search, 'graph>: Iterator<Item = Self::EdgeReference<'graph>>
where Self: 'graph;
type VertexIter<'search, 'graph>: Iterator<Item = Self::VertexReference<'graph>>
where Self: 'graph;
Show 14 methods
// Required methods
fn add_vertex(&mut self, vertex: Self::Vertex) -> Self::VertexId;
fn add_edge(
&mut self,
from: Self::VertexId,
to: Self::VertexId,
edge: Self::Edge,
) -> Self::EdgeId;
fn remove_vertex(&mut self, id: Self::VertexId) -> Option<Self::Vertex>;
fn remove_edge(&mut self, id: Self::EdgeId) -> Option<Self::Edge>;
fn vertex(&self, id: Self::VertexId) -> Option<Self::VertexReference<'_>>;
fn vertex_mut(
&mut self,
id: Self::VertexId,
) -> Option<Self::VertexReferenceMut<'_>>;
fn vertices<'search>(
&self,
vertex_search: &VertexSearch<'search, Self>,
) -> Self::VertexIter<'search, '_>;
fn edge(&self, id: Self::EdgeId) -> Option<Self::EdgeReference<'_>>;
fn edge_mut(
&mut self,
id: Self::EdgeId,
) -> Option<Self::EdgeReferenceMut<'_>>;
fn edges<'search>(
&self,
id: Self::VertexId,
search: &EdgeSearch<'search, Self>,
) -> Self::EdgeIter<'search, '_>;
// Provided methods
fn clear(&mut self) { ... }
fn dbg<T: Into<ElementId<Self>>>(&self, id: T) -> String { ... }
fn walk(&self) -> StartWalkerBuilder<'_, ImmutableMarker, Self, ()>
where Self: Sized { ... }
fn walk_mut(&mut self) -> StartWalkerBuilder<'_, MutableMarker, Self, ()>
where Self: Sized { ... }
}
Expand description
Graphs that implement this trait can be used with the walker API.
Required Associated Types§
Sourcetype VertexId: Debug + Eq + PartialEq + Copy + Clone + Hash + Into<ElementId<Self>> + 'static
type VertexId: Debug + Eq + PartialEq + Copy + Clone + Hash + Into<ElementId<Self>> + 'static
The VertexId
type of the graph.
Sourcetype EdgeId: Debug + Eq + PartialEq + Copy + Clone + Hash + Into<ElementId<Self>> + 'static
type EdgeId: Debug + Eq + PartialEq + Copy + Clone + Hash + Into<ElementId<Self>> + 'static
The EdgeId
type of the graph.
Sourcetype VertexReference<'graph>: VertexReference<'graph, Self>
where
Self: 'graph
type VertexReference<'graph>: VertexReference<'graph, Self> where Self: 'graph
A reference to a vertex.
Sourcetype VertexReferenceMut<'graph>: VertexReferenceMut<'graph, Self>
where
Self: 'graph
type VertexReferenceMut<'graph>: VertexReferenceMut<'graph, Self> where Self: 'graph
A mut reference to a vertex.
Sourcetype EdgeReference<'graph>: EdgeReference<'graph, Self>
where
Self: 'graph
type EdgeReference<'graph>: EdgeReference<'graph, Self> where Self: 'graph
An edge reference is used during walking over edges. It includes the id, tail, head and weight of the edge.
Sourcetype EdgeReferenceMut<'graph>: EdgeReferenceMut<'graph, Self>
where
Self: 'graph
type EdgeReferenceMut<'graph>: EdgeReferenceMut<'graph, Self> where Self: 'graph
A mut edge reference to modify the edge.
Sourcetype EdgeIter<'search, 'graph>: Iterator<Item = Self::EdgeReference<'graph>>
where
Self: 'graph
type EdgeIter<'search, 'graph>: Iterator<Item = Self::EdgeReference<'graph>> where Self: 'graph
An iterator over the edge references.
Sourcetype VertexIter<'search, 'graph>: Iterator<Item = Self::VertexReference<'graph>>
where
Self: 'graph
type VertexIter<'search, 'graph>: Iterator<Item = Self::VertexReference<'graph>> where Self: 'graph
An iterator over the vertex references.
Required Methods§
Sourcefn add_vertex(&mut self, vertex: Self::Vertex) -> Self::VertexId
fn add_vertex(&mut self, vertex: Self::Vertex) -> Self::VertexId
Adds a vertex to the graph and returns its identifier.
Sourcefn add_edge(
&mut self,
from: Self::VertexId,
to: Self::VertexId,
edge: Self::Edge,
) -> Self::EdgeId
fn add_edge( &mut self, from: Self::VertexId, to: Self::VertexId, edge: Self::Edge, ) -> Self::EdgeId
Adds an edge to the graph and returns its identifier.
Sourcefn remove_vertex(&mut self, id: Self::VertexId) -> Option<Self::Vertex>
fn remove_vertex(&mut self, id: Self::VertexId) -> Option<Self::Vertex>
Removes a vertex from the graph and returns the vertex.
Sourcefn remove_edge(&mut self, id: Self::EdgeId) -> Option<Self::Edge>
fn remove_edge(&mut self, id: Self::EdgeId) -> Option<Self::Edge>
Removes an edge from the graph and returns the edge.
Sourcefn vertex(&self, id: Self::VertexId) -> Option<Self::VertexReference<'_>>
fn vertex(&self, id: Self::VertexId) -> Option<Self::VertexReference<'_>>
Gets the vertex with the specified identifier.
Sourcefn vertex_mut(
&mut self,
id: Self::VertexId,
) -> Option<Self::VertexReferenceMut<'_>>
fn vertex_mut( &mut self, id: Self::VertexId, ) -> Option<Self::VertexReferenceMut<'_>>
Returns the vertex with the specified identifier.
Sourcefn vertices<'search>(
&self,
vertex_search: &VertexSearch<'search, Self>,
) -> Self::VertexIter<'search, '_>
fn vertices<'search>( &self, vertex_search: &VertexSearch<'search, Self>, ) -> Self::VertexIter<'search, '_>
Iterate over vertex identifiers. Graphs should try to narrow down the returned vertices using the search criteria, but overfetch will be filtered.
Sourcefn edge(&self, id: Self::EdgeId) -> Option<Self::EdgeReference<'_>>
fn edge(&self, id: Self::EdgeId) -> Option<Self::EdgeReference<'_>>
Gets the edge with the specified identifier.
Sourcefn edge_mut(&mut self, id: Self::EdgeId) -> Option<Self::EdgeReferenceMut<'_>>
fn edge_mut(&mut self, id: Self::EdgeId) -> Option<Self::EdgeReferenceMut<'_>>
Gets the edge with the specified identifier.
Sourcefn edges<'search>(
&self,
id: Self::VertexId,
search: &EdgeSearch<'search, Self>,
) -> Self::EdgeIter<'search, '_>
fn edges<'search>( &self, id: Self::VertexId, search: &EdgeSearch<'search, Self>, ) -> Self::EdgeIter<'search, '_>
Returns an iterator over the edges of a vertex. Graphs should try to narrow down the returned edges using the search criteria, but overfetch will be filtered.
Provided Methods§
Sourcefn clear(&mut self)
fn clear(&mut self)
Clears the graph. Default implementation returns an error.
Implement the SupportsClear
trait to provide this functionality.
Sourcefn dbg<T: Into<ElementId<Self>>>(&self, id: T) -> String
fn dbg<T: Into<ElementId<Self>>>(&self, id: T) -> String
Returns a string representation of an element in the graph.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.