Trait Graph

Source
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§

Source

type Vertex: Debug + Element

The type of the vertices in the graph. This is usually an enum.

Source

type Edge: Debug + Element

The type of the edges in the graph. This is usually an enum.

Source

type VertexId: Debug + Eq + PartialEq + Copy + Clone + Hash + Into<ElementId<Self>> + 'static

The VertexId type of the graph.

Source

type EdgeId: Debug + Eq + PartialEq + Copy + Clone + Hash + Into<ElementId<Self>> + 'static

The EdgeId type of the graph.

Source

type VertexReference<'graph>: VertexReference<'graph, Self> where Self: 'graph

A reference to a vertex.

Source

type VertexReferenceMut<'graph>: VertexReferenceMut<'graph, Self> where Self: 'graph

A mut reference to a vertex.

Source

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.

Source

type EdgeReferenceMut<'graph>: EdgeReferenceMut<'graph, Self> where Self: 'graph

A mut edge reference to modify the edge.

Source

type EdgeIter<'search, 'graph>: Iterator<Item = Self::EdgeReference<'graph>> where Self: 'graph

An iterator over the edge references.

Source

type VertexIter<'search, 'graph>: Iterator<Item = Self::VertexReference<'graph>> where Self: 'graph

An iterator over the vertex references.

Required Methods§

Source

fn add_vertex(&mut self, vertex: Self::Vertex) -> Self::VertexId

Adds a vertex to the graph and returns its identifier.

Source

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.

Source

fn remove_vertex(&mut self, id: Self::VertexId) -> Option<Self::Vertex>

Removes a vertex from the graph and returns the vertex.

Source

fn remove_edge(&mut self, id: Self::EdgeId) -> Option<Self::Edge>

Removes an edge from the graph and returns the edge.

Source

fn vertex(&self, id: Self::VertexId) -> Option<Self::VertexReference<'_>>

Gets the vertex with the specified identifier.

Source

fn vertex_mut( &mut self, id: Self::VertexId, ) -> Option<Self::VertexReferenceMut<'_>>

Returns the vertex with the specified identifier.

Source

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.

Source

fn edge(&self, id: Self::EdgeId) -> Option<Self::EdgeReference<'_>>

Gets the edge with the specified identifier.

Source

fn edge_mut(&mut self, id: Self::EdgeId) -> Option<Self::EdgeReferenceMut<'_>>

Gets the edge with the specified identifier.

Source

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§

Source

fn clear(&mut self)

Clears the graph. Default implementation returns an error. Implement the SupportsClear trait to provide this functionality.

Source

fn dbg<T: Into<ElementId<Self>>>(&self, id: T) -> String

Returns a string representation of an element in the graph.

Source

fn walk(&self) -> StartWalkerBuilder<'_, ImmutableMarker, Self, ()>
where Self: Sized,

Returns an immutable walker builder for the graph.

Source

fn walk_mut(&mut self) -> StartWalkerBuilder<'_, MutableMarker, Self, ()>
where Self: Sized,

Returns a mutable walker builder for 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.

Implementors§