use crate::Direction;
use crate::element::Element;
#[non_exhaustive]
pub struct EdgeSearch<'search, Graph>
where
Graph: crate::Graph,
{
_phantom: std::marker::PhantomData<&'search ()>,
pub label: Option<<Graph::Edge as Element>::Label>,
pub adjacent_label: Option<<Graph::Vertex as Element>::Label>,
pub direction: Direction,
pub limit: Option<usize>,
}
impl<Graph> Clone for EdgeSearch<'_, Graph>
where
Graph: crate::Graph,
{
fn clone(&self) -> Self {
EdgeSearch {
_phantom: Default::default(),
label: self.label,
adjacent_label: self.adjacent_label,
direction: self.direction,
limit: self.limit,
}
}
}
impl<Graph> Default for EdgeSearch<'_, Graph>
where
Graph: crate::Graph,
{
fn default() -> Self {
Self {
_phantom: Default::default(),
label: None,
adjacent_label: None,
direction: Direction::All,
limit: None,
}
}
}
impl<Graph> EdgeSearch<'_, Graph>
where
Graph: crate::Graph,
{
pub fn scan() -> Self {
Self::default()
}
pub fn label(label: <Graph::Edge as Element>::Label) -> Self {
Self {
_phantom: Default::default(),
label: Some(label),
adjacent_label: None,
direction: Direction::All,
limit: None,
}
}
pub fn outgoing(mut self) -> Self {
self.direction = Direction::Outgoing;
self
}
pub fn incoming(mut self) -> Self {
self.direction = Direction::Incoming;
self
}
pub fn direction(mut self, direction: Direction) -> Self {
self.direction = direction;
self
}
pub fn take(mut self, n: usize) -> Self {
self.limit = Some(n);
self
}
pub fn with_limit(mut self, limit: usize) -> Self {
self.limit = Some(limit);
self
}
pub fn limit(&self) -> usize {
self.limit.unwrap_or(usize::MAX)
}
pub fn adjacent_labelled(mut self, adjacent_label: <Graph::Vertex as Element>::Label) -> Self
where
Graph: crate::Graph + crate::SupportsEdgeAdjacentLabelIndex,
{
self.adjacent_label = Some(adjacent_label);
self
}
}