From c4da4ceadd4836a1947d0d100b252000018fc0d1 Mon Sep 17 00:00:00 2001 From: meliurwen Date: Thu, 16 Feb 2023 14:56:20 +0100 Subject: [PATCH] Added `get_adj_matrix()` --- reCTBN/src/process.rs | 2 ++ reCTBN/src/process/ctbn.rs | 5 +++++ reCTBN/src/process/ctmp.rs | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/reCTBN/src/process.rs b/reCTBN/src/process.rs index 45c5e0a..f554af4 100644 --- a/reCTBN/src/process.rs +++ b/reCTBN/src/process.rs @@ -5,6 +5,7 @@ pub mod ctmp; use std::collections::BTreeSet; +use ndarray::Array2; use thiserror::Error; use crate::params; @@ -117,4 +118,5 @@ pub trait NetworkProcess: Sync { /// /// * The **children set** of the selected node. fn get_children_set(&self, node: usize) -> BTreeSet; + fn get_adj_matrix(&self) -> Option>; } diff --git a/reCTBN/src/process/ctbn.rs b/reCTBN/src/process/ctbn.rs index 162345e..9784776 100644 --- a/reCTBN/src/process/ctbn.rs +++ b/reCTBN/src/process/ctbn.rs @@ -240,4 +240,9 @@ impl process::NetworkProcess for CtbnNetwork { .filter_map(|(idx, x)| if x > &0 { Some(idx) } else { None }) .collect() } + + /// Get the Adjacency Matrix. + fn get_adj_matrix(&self) -> Option> { + self.adj_matrix.clone() + } } diff --git a/reCTBN/src/process/ctmp.rs b/reCTBN/src/process/ctmp.rs index 41b8db6..4a346e7 100644 --- a/reCTBN/src/process/ctmp.rs +++ b/reCTBN/src/process/ctmp.rs @@ -1,5 +1,7 @@ use std::collections::BTreeSet; +use ndarray::Array2; + use crate::{ params::{Params, StateType}, process, @@ -111,4 +113,7 @@ impl NetworkProcess for CtmpProcess { None => panic!("Uninitialized CtmpProcess"), } } + fn get_adj_matrix(&self) -> Option> { + unimplemented!("CtmpProcess has only one node") + } }