[][src]Trait ojo_graph::Graph

pub trait Graph {
    type Node: Copy + Eq + Hash;
    type Edge: Copy + Eq + Edge<Self::Node>;
    fn nodes<'a>(&'a self) -> Box<dyn Iterator<Item = Self::Node> + 'a>;
fn out_edges<'a>(
        &'a self,
        u: &Self::Node
    ) -> Box<dyn Iterator<Item = Self::Edge> + 'a>;
fn in_edges<'a>(
        &'a self,
        u: &Self::Node
    ) -> Box<dyn Iterator<Item = Self::Edge> + 'a>; fn out_neighbors<'a>(
        &'a self,
        u: &Self::Node
    ) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node> { ... }
fn in_neighbors<'a>(
        &'a self,
        u: &Self::Node
    ) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node> { ... }
fn dfs<'a>(&'a self) -> Dfs<'a, Self> { ... }
fn dfs_from<'a>(&'a self, root: &Self::Node) -> Dfs<'a, Self> { ... }
fn has_path(&self, u: &Self::Node, v: &Self::Node) -> bool { ... }
fn tarjan(&self) -> Partition<Self> { ... }
fn weak_components(&self) -> Partition<Self> { ... }
fn doubled<'a>(&'a self) -> Doubled<'a, Self> { ... }
fn node_filtered<'a, F>(&'a self, predicate: F) -> NodeFiltered<'a, Self, F>
    where
        F: Fn(&Self::Node) -> bool
, { ... }
fn edge_filtered<'a, F>(&'a self, predicate: F) -> EdgeFiltered<'a, Self, F>
    where
        F: Fn(&Self::Node, &Self::Edge) -> bool
, { ... }
fn top_sort<'a>(&'a self) -> Option<Vec<Self::Node>> { ... }
fn linear_order<'a>(&'a self) -> Option<Vec<Self::Node>> { ... }
fn neighbor_set<'a, I: Iterator<Item = &'a Self::Node>>(
        &self,
        set: I
    ) -> HashSet<Self::Node>
    where
        Self::Node: 'a
, { ... } }

Associated Types

type Node: Copy + Eq + Hash

type Edge: Copy + Eq + Edge<Self::Node>

Loading content...

Required methods

fn nodes<'a>(&'a self) -> Box<dyn Iterator<Item = Self::Node> + 'a>

fn out_edges<'a>(
    &'a self,
    u: &Self::Node
) -> Box<dyn Iterator<Item = Self::Edge> + 'a>

fn in_edges<'a>(
    &'a self,
    u: &Self::Node
) -> Box<dyn Iterator<Item = Self::Edge> + 'a>

Loading content...

Provided methods

fn out_neighbors<'a>(
    &'a self,
    u: &Self::Node
) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node>

fn in_neighbors<'a>(
    &'a self,
    u: &Self::Node
) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node>

Important traits for Dfs<'a, G>
fn dfs<'a>(&'a self) -> Dfs<'a, Self>

Important traits for Dfs<'a, G>
fn dfs_from<'a>(&'a self, root: &Self::Node) -> Dfs<'a, Self>

fn has_path(&self, u: &Self::Node, v: &Self::Node) -> bool

fn tarjan(&self) -> Partition<Self>

fn weak_components(&self) -> Partition<Self>

fn doubled<'a>(&'a self) -> Doubled<'a, Self>

Returns the graph that has edges in both directions for every edge that this graph has in one direction.

fn node_filtered<'a, F>(&'a self, predicate: F) -> NodeFiltered<'a, Self, F> where
    F: Fn(&Self::Node) -> bool

Returns the subgraph of this graph that is induced by the set of nodes for which predicate returns true.

fn edge_filtered<'a, F>(&'a self, predicate: F) -> EdgeFiltered<'a, Self, F> where
    F: Fn(&Self::Node, &Self::Edge) -> bool

Returns the subgraph of this graph containing all the edges for which the predicate returns true.

fn top_sort<'a>(&'a self) -> Option<Vec<Self::Node>>

If this graph is acyclic, returns a topological sort of the vertices. Otherwise, returns None.

fn linear_order<'a>(&'a self) -> Option<Vec<Self::Node>>

fn neighbor_set<'a, I: Iterator<Item = &'a Self::Node>>(
    &self,
    set: I
) -> HashSet<Self::Node> where
    Self::Node: 'a, 

Returns the set of all nodes that are adjacent (either an in-neighbor or an out-neighbor) to something in set.

Loading content...

Implementors

impl<'a, G: ?Sized> Graph for Doubled<'a, G> where
    G: Graph
[src]

type Node = G::Node

type Edge = G::Edge

fn out_neighbors<'a>(
    &'a self,
    u: &Self::Node
) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node>
[src]

fn in_neighbors<'a>(
    &'a self,
    u: &Self::Node
) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node>
[src]

Important traits for Dfs<'a, G>
fn dfs<'a>(&'a self) -> Dfs<'a, Self>[src]

Important traits for Dfs<'a, G>
fn dfs_from<'a>(&'a self, root: &Self::Node) -> Dfs<'a, Self>[src]

fn has_path(&self, u: &Self::Node, v: &Self::Node) -> bool[src]

fn tarjan(&self) -> Partition<Self>[src]

fn weak_components(&self) -> Partition<Self>[src]

fn doubled<'a>(&'a self) -> Doubled<'a, Self>[src]

fn node_filtered<'a, F>(&'a self, predicate: F) -> NodeFiltered<'a, Self, F> where
    F: Fn(&Self::Node) -> bool
[src]

fn edge_filtered<'a, F>(&'a self, predicate: F) -> EdgeFiltered<'a, Self, F> where
    F: Fn(&Self::Node, &Self::Edge) -> bool
[src]

fn top_sort<'a>(&'a self) -> Option<Vec<Self::Node>>[src]

fn linear_order<'a>(&'a self) -> Option<Vec<Self::Node>>[src]

fn neighbor_set<'a, I: Iterator<Item = &'a Self::Node>>(
    &self,
    set: I
) -> HashSet<Self::Node> where
    Self::Node: 'a, 
[src]

impl<'a, G: ?Sized, F> Graph for EdgeFiltered<'a, G, F> where
    G: Graph,
    F: Fn(&G::Node, &G::Edge) -> bool + 'a, 
[src]

type Node = G::Node

type Edge = G::Edge

fn out_neighbors<'a>(
    &'a self,
    u: &Self::Node
) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node>
[src]

fn in_neighbors<'a>(
    &'a self,
    u: &Self::Node
) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node>
[src]

Important traits for Dfs<'a, G>
fn dfs<'a>(&'a self) -> Dfs<'a, Self>[src]

Important traits for Dfs<'a, G>
fn dfs_from<'a>(&'a self, root: &Self::Node) -> Dfs<'a, Self>[src]

fn has_path(&self, u: &Self::Node, v: &Self::Node) -> bool[src]

fn tarjan(&self) -> Partition<Self>[src]

fn weak_components(&self) -> Partition<Self>[src]

fn doubled<'a>(&'a self) -> Doubled<'a, Self>[src]

fn node_filtered<'a, F>(&'a self, predicate: F) -> NodeFiltered<'a, Self, F> where
    F: Fn(&Self::Node) -> bool
[src]

fn edge_filtered<'a, F>(&'a self, predicate: F) -> EdgeFiltered<'a, Self, F> where
    F: Fn(&Self::Node, &Self::Edge) -> bool
[src]

fn top_sort<'a>(&'a self) -> Option<Vec<Self::Node>>[src]

fn linear_order<'a>(&'a self) -> Option<Vec<Self::Node>>[src]

fn neighbor_set<'a, I: Iterator<Item = &'a Self::Node>>(
    &self,
    set: I
) -> HashSet<Self::Node> where
    Self::Node: 'a, 
[src]

impl<'a, G: ?Sized, F> Graph for NodeFiltered<'a, G, F> where
    G: Graph,
    F: Fn(&G::Node) -> bool + 'a, 
[src]

type Node = G::Node

type Edge = G::Edge

fn out_neighbors<'a>(
    &'a self,
    u: &Self::Node
) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node>
[src]

fn in_neighbors<'a>(
    &'a self,
    u: &Self::Node
) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node>
[src]

Important traits for Dfs<'a, G>
fn dfs<'a>(&'a self) -> Dfs<'a, Self>[src]

Important traits for Dfs<'a, G>
fn dfs_from<'a>(&'a self, root: &Self::Node) -> Dfs<'a, Self>[src]

fn has_path(&self, u: &Self::Node, v: &Self::Node) -> bool[src]

fn tarjan(&self) -> Partition<Self>[src]

fn weak_components(&self) -> Partition<Self>[src]

fn doubled<'a>(&'a self) -> Doubled<'a, Self>[src]

fn node_filtered<'a, F>(&'a self, predicate: F) -> NodeFiltered<'a, Self, F> where
    F: Fn(&Self::Node) -> bool
[src]

fn edge_filtered<'a, F>(&'a self, predicate: F) -> EdgeFiltered<'a, Self, F> where
    F: Fn(&Self::Node, &Self::Edge) -> bool
[src]

fn top_sort<'a>(&'a self) -> Option<Vec<Self::Node>>[src]

fn linear_order<'a>(&'a self) -> Option<Vec<Self::Node>>[src]

fn neighbor_set<'a, I: Iterator<Item = &'a Self::Node>>(
    &self,
    set: I
) -> HashSet<Self::Node> where
    Self::Node: 'a, 
[src]

impl<G: Graph + ?Sized> Graph for Partition<G>[src]

type Node = usize

type Edge = usize

fn out_neighbors<'a>(
    &'a self,
    u: &Self::Node
) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node>
[src]

fn in_neighbors<'a>(
    &'a self,
    u: &Self::Node
) -> Map<Box<dyn Iterator<Item = Self::Edge> + 'a>, fn(_: Self::Edge) -> Self::Node>
[src]

Important traits for Dfs<'a, G>
fn dfs<'a>(&'a self) -> Dfs<'a, Self>[src]

Important traits for Dfs<'a, G>
fn dfs_from<'a>(&'a self, root: &Self::Node) -> Dfs<'a, Self>[src]

fn has_path(&self, u: &Self::Node, v: &Self::Node) -> bool[src]

fn tarjan(&self) -> Partition<Self>[src]

fn weak_components(&self) -> Partition<Self>[src]

fn doubled<'a>(&'a self) -> Doubled<'a, Self>[src]

fn node_filtered<'a, F>(&'a self, predicate: F) -> NodeFiltered<'a, Self, F> where
    F: Fn(&Self::Node) -> bool
[src]

fn edge_filtered<'a, F>(&'a self, predicate: F) -> EdgeFiltered<'a, Self, F> where
    F: Fn(&Self::Node, &Self::Edge) -> bool
[src]

fn top_sort<'a>(&'a self) -> Option<Vec<Self::Node>>[src]

fn linear_order<'a>(&'a self) -> Option<Vec<Self::Node>>[src]

fn neighbor_set<'a, I: Iterator<Item = &'a Self::Node>>(
    &self,
    set: I
) -> HashSet<Self::Node> where
    Self::Node: 'a, 
[src]

Loading content...