acme_graphs/
graph.rs

1/*
2    Appellation: graph <module>
3    Contrib: FL03 <jo3mccain@icloud.com>
4*/
5//! # Graph
6//!
7//! A computational graph forms the backbone of automatic differentiation. Computational graphs are directed acyclic graphs (DAGs)
8//! that represent any computation as a series of nodes and edges.
9//!
10//! In a dynamic computational graph (DCG), the graph considers the nodes to be tensors and the edges to be operations.
11//!
12
13pub trait GraphEntry {
14    type Idx;
15    type Weight;
16}
17
18pub trait ComputeGraph {
19    type Edge: GraphEntry;
20    type Node: GraphEntry;
21
22    fn add_node(
23        &mut self,
24        node: <Self::Node as GraphEntry>::Weight,
25    ) -> <Self::Node as GraphEntry>::Idx;
26
27    fn add_edge(
28        &mut self,
29        source: <Self::Node as GraphEntry>::Idx,
30        target: <Self::Node as GraphEntry>::Idx,
31        weight: <Self::Edge as GraphEntry>::Weight,
32    ) -> <Self::Edge as GraphEntry>::Idx;
33
34    fn clear(&mut self);
35}