Skip to content

yiminghe/suffix-tree

Repository files navigation

@yiminghe/suffix-tree


suffix tree

NPM version build status Test coverage node version npm download

usage

import SuffixTree from '@yiminghe/suffix-tree';
const tree = new SuffixTree("abceabc$");
console.log(tree.getLongestDupSubstr()); // => abc

API

class SuffixTree

methods

  • constructor(s:string)

construct a suffix tree using string s

  • getLongestDupSubstr():string

Return any duplicated substring that has the longest possible length.

members

  • root: SuffixTree

root node of suffix tree

  • next: Map<string, SuffixTreeNode>

map of next char to next SuffixTreeNode

class SuffixTreeNode

members

  • start: number

start position of string

methods

  • getEdgeLength(): number

edge string length

  • getEnd(): number

end position of string