Struct KGST

Source
pub struct KGST<T, U>{ /* 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>

Source

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('$');
Source

pub fn clear(&mut self)

Empties the tree of all strings and nodes.

Source

pub fn num_nodes(&self) -> usize

Source

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.

Source

pub fn get_nodes(&self) -> &HashMap<NodeID, Node<T>>

Source

pub fn get_node(&self, node_id: &NodeID) -> &Node<T>

Retrieves a node from the tree by node id

Source

pub fn get_node_label(&self, node_id: &NodeID) -> &[Character<T>]

Returns the string represented by the incoming edge of the node.

Source

pub fn suffix_match(&self, s: &[T]) -> HashMap<U, HashSet<usize>>

Retrieves all strings that the input slice is a suffix of.

Source

pub fn substring_match(&self, s: &[T]) -> HashMap<U, HashSet<usize>>

Retrieves all strings that contain the input slice as some substring.

Source

pub fn get_node_data( &self, node_id: &NodeID, ) -> &HashMap<StringID, HashSet<usize>>

Source

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.

Source

pub fn contains(&self, string_id: &U) -> bool

Source

pub fn iter_strings(&self) -> Iter<'_, usize, (TreeItem<T, U>, usize)>

Returns a string iterator of the tree

Source

pub fn print_tree(&self)

Prints tree as a string.

Source

pub fn iter_nodes_pre(&self) -> PreOrdNodes<T>

Returns a preorder node iterator of the tree

Source

pub fn iter_nodes_post(&self) -> PostOrdNodes<T>

Returns a preorder node iterator of the tree

Source

pub fn iter_path_pre(&self, node_id: &NodeID) -> IntoIter<usize>

Returns the nodes in a path in preorder

Source

pub fn iter_path_post(&self, node_id: &NodeID) -> IntoIter<usize>

Returns the nodes in a path in postorder

Source

pub fn iter_edges_post(&self) -> PostOrdEdges<T>

Returns a postorder edge iterator of the tree

Trait Implementations§

Source§

impl<T, U> Debug for KGST<T, U>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, U> Serialize for KGST<T, U>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T, U> SuffixTree<T> for KGST<T, U>

Source§

fn root(&self) -> &NodeID

Source§

fn is_leaf(&self, node_id: &NodeID) -> bool

Source§

fn get_node_child(&self, node_id: &NodeID, edge_label: &T) -> Option<&NodeID>

Source§

fn get_node_parent(&self, node_id: &NodeID) -> Option<&NodeID>

Source§

fn get_node_depth(&self, node_id: &NodeID) -> usize

Source§

fn get_node_label(&self, node_id: &NodeID) -> Vec<T>

Source§

fn get_node_path_label(&self, _node_id: &NodeID) -> &[T]

Source§

fn get_node_path_pre(&self, node_id: &NodeID) -> LinkedList<NodeID>

Source§

fn get_node_path_post(&self, node_id: &NodeID) -> LinkedList<NodeID>

Source§

fn is_suffix(&self, s: &[T]) -> bool

Checks if the input slice is a suffix of any of the strings present in the tree.

Auto Trait Implementations§

§

impl<T, U> Freeze for KGST<T, U>
where T: Freeze,

§

impl<T, U> RefUnwindSafe for KGST<T, U>

§

impl<T, U> Send for KGST<T, U>
where T: Send, U: Send,

§

impl<T, U> Sync for KGST<T, U>
where T: Sync, U: Sync,

§

impl<T, U> Unpin for KGST<T, U>
where T: Unpin, U: Unpin,

§

impl<T, U> UnwindSafe for KGST<T, U>
where T: UnwindSafe, U: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.