Struct nekolib::graph::FunctionalGraph
source · pub struct FunctionalGraph { /* private fields */ }
Expand description
function graph。
Todo
辺にモノイドを持たせて n 個進んだときの fold をするのは ダブリングテーブルとかが必要になって、周期検出をしたいだけのときには オーバーヘッドが大きそう。
なので、FoldableFunctionalGraph
とかを別に作ってみる。
それの内部でこれを持っても使えそう。
Complexity
$O(n)$ time.
Examples
+---> 1 ----+ +--- 6 <--- 5
| | |
| v |
| 2 <---+--- 7 12
0 |
^ v 8
| 3 <------ 11 |
| | v
+---- 4 <---+ 10 <------> 9
$i$ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
$f(i)$ | 1 | 2 | 3 | 4 | 0 | 6 | 2 | 2 | 9 | 10 | 9 | 3 | 12 |
$\mu_i$ | 0 | 0 | 0 | 0 | 0 | 2 | 1 | 1 | 1 | 0 | 0 | 1 | 0 |
$\lambda_i$ | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 2 | 2 | 2 | 5 | 1 |
use nekolib::graph::FunctionalGraph;
let f = vec![1, 2, 3, 4, 0, 6, 2, 2, 9, 10, 9, 3, 12];
let n = f.len();
let g: FunctionalGraph = f.into();
let mu = vec![0, 0, 0, 0, 0, 2, 1, 1, 1, 0, 0, 1, 0];
let lambda = vec![5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 2, 5, 1];
for i in 0..n {
assert_eq!(g.mu_lambda(i), (mu[i], lambda[i]));
}
Implementations§
Trait Implementations§
source§impl Clone for FunctionalGraph
impl Clone for FunctionalGraph
source§fn clone(&self) -> FunctionalGraph
fn clone(&self) -> FunctionalGraph
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for FunctionalGraph
impl Debug for FunctionalGraph
source§impl PartialEq<FunctionalGraph> for FunctionalGraph
impl PartialEq<FunctionalGraph> for FunctionalGraph
source§fn eq(&self, other: &FunctionalGraph) -> bool
fn eq(&self, other: &FunctionalGraph) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for FunctionalGraph
impl StructuralEq for FunctionalGraph
impl StructuralPartialEq for FunctionalGraph
Auto Trait Implementations§
impl RefUnwindSafe for FunctionalGraph
impl Send for FunctionalGraph
impl Sync for FunctionalGraph
impl Unpin for FunctionalGraph
impl UnwindSafe for FunctionalGraph
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more