pub struct KGST<T, U>where
T: Display + Debug + Eq + PartialEq + Hash + Clone + PartialOrd,
U: Display + Debug + Eq + PartialEq + Hash + Clone,{ /* private fields */ }
Expand description
A Generalized Truncated Suffix Tree implemented with a variation of Ukkonen’s Algorithm.
Implementations§
Source§impl<T, U> KGST<T, U>
impl<T, U> KGST<T, U>
Sourcepub fn new(terminal_character: T) -> Self
pub fn new(terminal_character: T) -> Self
Creates a new empty K-Truncated Generalized Suffix tree, with a constant end symbol.
§Examples
use generalized_suffix_tree::suffix_tree::KGST;
let tree: KGST<char, String> = KGST::new('$');
pub fn num_nodes(&self) -> usize
Sourcepub fn get_strings(&self) -> &HashMap<StringID, (TreeItem<T, U>, usize)>
pub fn get_strings(&self) -> &HashMap<StringID, (TreeItem<T, U>, usize)>
Returns a Hashmap of all the strings present in the tree along with their respective tree depth.
pub fn get_nodes(&self) -> &HashMap<NodeID, Node<T>>
Sourcepub fn get_node_label(&self, node_id: &NodeID) -> &[Character<T>]
pub fn get_node_label(&self, node_id: &NodeID) -> &[Character<T>]
Returns the string represented by the incoming edge of the node.
Sourcepub fn suffix_match(&self, s: &[T]) -> HashMap<U, HashSet<usize>>
pub fn suffix_match(&self, s: &[T]) -> HashMap<U, HashSet<usize>>
Retrieves all strings that the input slice is a suffix of.
Sourcepub fn substring_match(&self, s: &[T]) -> HashMap<U, HashSet<usize>>
pub fn substring_match(&self, s: &[T]) -> HashMap<U, HashSet<usize>>
Retrieves all strings that contain the input slice as some substring.
pub fn get_node_data( &self, node_id: &NodeID, ) -> &HashMap<StringID, HashSet<usize>>
Sourcepub fn insert(&mut self, k: U, v: Vec<T>, max_depth: &usize)
pub fn insert(&mut self, k: U, v: Vec<T>, max_depth: &usize)
inserts all suffixes of a string into the tree. If max_depth>0, all substrings of length==max_depth are inserted.
pub fn contains(&self, string_id: &U) -> bool
Sourcepub fn iter_strings(&self) -> Iter<'_, usize, (TreeItem<T, U>, usize)>
pub fn iter_strings(&self) -> Iter<'_, usize, (TreeItem<T, U>, usize)>
Returns a string iterator of the tree
Sourcepub fn print_tree(&self)
pub fn print_tree(&self)
Prints tree as a string.
Sourcepub fn iter_nodes_pre(&self) -> PreOrdNodes<T> ⓘ
pub fn iter_nodes_pre(&self) -> PreOrdNodes<T> ⓘ
Returns a preorder node iterator of the tree
Sourcepub fn iter_nodes_post(&self) -> PostOrdNodes<T> ⓘ
pub fn iter_nodes_post(&self) -> PostOrdNodes<T> ⓘ
Returns a preorder node iterator of the tree
Sourcepub fn iter_path_pre(&self, node_id: &NodeID) -> IntoIter<usize>
pub fn iter_path_pre(&self, node_id: &NodeID) -> IntoIter<usize>
Returns the nodes in a path in preorder
Sourcepub fn iter_path_post(&self, node_id: &NodeID) -> IntoIter<usize>
pub fn iter_path_post(&self, node_id: &NodeID) -> IntoIter<usize>
Returns the nodes in a path in postorder
Sourcepub fn iter_edges_post(&self) -> PostOrdEdges<T> ⓘ
pub fn iter_edges_post(&self) -> PostOrdEdges<T> ⓘ
Returns a postorder edge iterator of the tree
Trait Implementations§
Source§impl<T, U> SuffixTree<T> for KGST<T, U>
impl<T, U> SuffixTree<T> for KGST<T, U>
fn root(&self) -> &NodeID
fn is_leaf(&self, node_id: &NodeID) -> bool
fn get_node_child(&self, node_id: &NodeID, edge_label: &T) -> Option<&NodeID>
fn get_node_parent(&self, node_id: &NodeID) -> Option<&NodeID>
fn get_node_depth(&self, node_id: &NodeID) -> usize
fn get_suffix_link(&self, node_id: &NodeID) -> &usize
fn get_node_label(&self, node_id: &NodeID) -> Vec<T>
fn get_node_path_label(&self, _node_id: &NodeID) -> &[T]
fn get_node_path_pre(&self, node_id: &NodeID) -> LinkedList<NodeID>
fn get_node_path_post(&self, node_id: &NodeID) -> LinkedList<NodeID>
Auto Trait Implementations§
impl<T, U> Freeze for KGST<T, U>where
T: Freeze,
impl<T, U> RefUnwindSafe for KGST<T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for KGST<T, U>
impl<T, U> Sync for KGST<T, U>
impl<T, U> Unpin for KGST<T, U>
impl<T, U> UnwindSafe for KGST<T, U>where
T: UnwindSafe,
U: UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more