Struct auto_diff::collection::directed_graph::Graph
source · [−]Expand description
Graph
Implementations
sourceimpl<TData: Clone + Copy + Ord, TOp: Clone + Copy + Ord> Graph<TData, TOp>
impl<TData: Clone + Copy + Ord, TOp: Clone + Copy + Ord> Graph<TData, TOp>
sourcepub fn iter_data(&self) -> NodeIterator<'_, TData>ⓘNotable traits for NodeIterator<'a, TNode>impl<'a, TNode> Iterator for NodeIterator<'a, TNode> type Item = &'a TNode;
pub fn iter_data(&self) -> NodeIterator<'_, TData>ⓘNotable traits for NodeIterator<'a, TNode>impl<'a, TNode> Iterator for NodeIterator<'a, TNode> type Item = &'a TNode;
iterator over data node.
sourcepub fn iter_op(&self) -> NodeIterator<'_, TOp>ⓘNotable traits for NodeIterator<'a, TNode>impl<'a, TNode> Iterator for NodeIterator<'a, TNode> type Item = &'a TNode;
pub fn iter_op(&self) -> NodeIterator<'_, TOp>ⓘNotable traits for NodeIterator<'a, TNode>impl<'a, TNode> Iterator for NodeIterator<'a, TNode> type Item = &'a TNode;
iterator over op node.
sourcepub fn iter_op_given_input(
&self,
var: &TData
) -> Result<NodeIterator<'_, TOp>, &str>
pub fn iter_op_given_input(
&self,
var: &TData
) -> Result<NodeIterator<'_, TOp>, &str>
Return the list of ops that the given variable is the input of the func.
sourcepub fn iter_op_given_output(
&self,
var: &TData
) -> Result<NodeIterator<'_, TOp>, &str>
pub fn iter_op_given_output(
&self,
var: &TData
) -> Result<NodeIterator<'_, TOp>, &str>
Return the list of ops that the given variable is the output.
sourcepub fn iter_input_given_op(
&self,
func: &TOp
) -> Result<NodeIterator<'_, TData>, &str>
pub fn iter_input_given_op(
&self,
func: &TOp
) -> Result<NodeIterator<'_, TData>, &str>
Return the list of input given the func.
sourcepub fn iter_output_given_op(
&self,
func: &TOp
) -> Result<NodeIterator<'_, TData>, &str>
pub fn iter_output_given_op(
&self,
func: &TOp
) -> Result<NodeIterator<'_, TData>, &str>
Return a list of data as the output of the op.
sourcepub fn drop_data(&mut self, id: &TData) -> Result<TData, &str>
pub fn drop_data(&mut self, id: &TData) -> Result<TData, &str>
Remove a data node, op node and downstream data/op node are removed.
sourcepub fn drop_op(&mut self, id: &TOp) -> Result<TOp, &str>
pub fn drop_op(&mut self, id: &TOp) -> Result<TOp, &str>
Remvoe an op node, input data node and downstream data/op node are removed.
sourcepub fn decouple_data_func(
&mut self,
var: &TData,
func: &TOp
) -> Result<(), AutoDiffError>
pub fn decouple_data_func(
&mut self,
var: &TData,
func: &TOp
) -> Result<(), AutoDiffError>
Decouple input variable and op
sourcepub fn decouple_func_data(
&mut self,
func: &TOp,
var: &TData
) -> Result<(), AutoDiffError>
pub fn decouple_func_data(
&mut self,
func: &TOp,
var: &TData
) -> Result<(), AutoDiffError>
Decouple op and output variable
sourcepub fn get_input_edge_data(&self) -> BTreeSet<TData>
pub fn get_input_edge_data(&self) -> BTreeSet<TData>
list data node without upstream op node in a set.
sourcepub fn get_output_edge_data(&self) -> BTreeSet<TData>
pub fn get_output_edge_data(&self) -> BTreeSet<TData>
list data node without downstream op node in a set.
sourcepub fn connect(
&mut self,
dti: &[TData],
dto: &[TData],
op: &TOp
) -> Result<TOp, &str>
pub fn connect(
&mut self,
dti: &[TData],
dto: &[TData],
op: &TOp
) -> Result<TOp, &str>
Connect input data, output data and operation
sourcepub fn connect_aux(
&mut self,
input_data: &[TData],
output_data: &[TData],
op: &TOp
) -> Result<TOp, &str>
pub fn connect_aux(
&mut self,
input_data: &[TData],
output_data: &[TData],
op: &TOp
) -> Result<TOp, &str>
Auxilary connect, This allows the graph to support loop.
sourcepub fn walk<F>(
&self,
start_set: &[TData],
forward: bool,
closure: F
) -> Result<(), BTreeSet<TData>> where
F: Fn(&[TData], &[TData], &TOp),
pub fn walk<F>(
&self,
start_set: &[TData],
forward: bool,
closure: F
) -> Result<(), BTreeSet<TData>> where
F: Fn(&[TData], &[TData], &TOp),
Walk through the graph with a starting set of data nodes. Go through backwards if forward is false. The closure call provides the side-effect.
This Walk() guarantee the input of visiting op is already visited or it’s an input.
Trait Implementations
sourceimpl<'de, TData: Ord, TOp: Ord> Deserialize<'de> for Graph<TData, TOp> where
TData: Deserialize<'de>,
TOp: Deserialize<'de>,
impl<'de, TData: Ord, TOp: Ord> Deserialize<'de> for Graph<TData, TOp> where
TData: Deserialize<'de>,
TOp: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<TData: Ord, TOp: Ord> Serialize for Graph<TData, TOp> where
TData: Serialize,
TOp: Serialize,
impl<TData: Ord, TOp: Ord> Serialize for Graph<TData, TOp> where
TData: Serialize,
TOp: Serialize,
impl<T1: Ord, T2: Ord> Eq for Graph<T1, T2>
Auto Trait Implementations
impl<TData, TOp> RefUnwindSafe for Graph<TData, TOp> where
TData: RefUnwindSafe,
TOp: RefUnwindSafe,
impl<TData, TOp> Send for Graph<TData, TOp> where
TData: Send,
TOp: Send,
impl<TData, TOp> Sync for Graph<TData, TOp> where
TData: Sync,
TOp: Sync,
impl<TData, TOp> Unpin for Graph<TData, TOp>
impl<TData, TOp> UnwindSafe for Graph<TData, TOp> where
TData: RefUnwindSafe,
TOp: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more