< Summary

Information
Class: MoreStructures.SuffixStructures.Conversions.PartiallyIterativeConverter
Assembly: MoreStructures
File(s): /home/runner/work/MoreStructures/MoreStructures/MoreStructures/SuffixStructures/Conversions/PartiallyIterativeConverter.cs
Line coverage
100%
Covered lines: 28
Uncovered lines: 0
Coverable lines: 28
Total lines: 67
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
TrieToTree(...)100%4100%
TreeToTrie(...)100%4100%

File(s)

/home/runner/work/MoreStructures/MoreStructures/MoreStructures/SuffixStructures/Conversions/PartiallyIterativeConverter.cs

#LineLine coverage
 1using MoreStructures.SuffixTrees;
 2using MoreStructures.SuffixTries;
 3
 4namespace MoreStructures.SuffixStructures.Conversions;
 5
 6using static ConverterHelpers;
 7
 8/// <summary>
 9/// <inheritdoc cref="IConverter"/>
 10/// </summary>
 11/// <remarks>
 12/// Conversion is iteratively for no-branching paths (i.e. on nodes having a single child) and recursively on
 13/// branching of the input <see cref="SuffixTrieNode"/>, with occasional mutation of internal state of the
 14/// conversion.
 15/// Limited by stack depth (but less than <see cref="FullyRecursiveConverter"/>) and usable with output trees of a
 16/// "reasonable" height (i.e. trees having a height &lt; ~1K nodes).
 17/// </remarks>
 18public class PartiallyIterativeConverter : IConverter
 19{
 20    /// <inheritdoc path="//*[not(self::summary or self::remarks)]"/>
 21    /// <summary>
 22    ///     <inheritdoc/>
 23    /// </summary>
 24    /// <remarks>
 25    ///     <inheritdoc cref="PartiallyIterativeConverter" path="/remarks"/>
 26    ///     <inheritdoc cref="IConverter.TrieToTree(SuffixTrieNode)" path="/remarks"/>
 27    /// </remarks>
 28    public SuffixTreeNode TrieToTree(SuffixTrieNode trieNode) =>
 3629        trieNode switch
 3630        {
 3631            SuffixTrieNode.Leaf(var leafStart) =>
 1832                new SuffixTreeNode.Leaf(leafStart),
 3633
 3634            SuffixTrieNode.Intermediate(var trieNodeChildren) =>
 1735                new SuffixTreeNode.Intermediate(new Dictionary<SuffixTreeEdge, SuffixTreeNode>(
 1736                    from trieChild in trieNodeChildren
 2437                    let coalescedChild = IterativeCoalesce(trieChild.Key, trieChild.Value)
 2338                    let coalescedTreeChildNode = TrieToTree(coalescedChild.coalescedTrieNode)
 3939                    select KeyValuePair.Create(coalescedChild.coalescedTreeEdge, coalescedTreeChildNode))),
 3640
 141            _ => throw new NotSupportedException($"{trieNode} of type {trieNode.GetType().Name} not supported")
 3642        };
 43
 44    /// <inheritdoc path="//*[not(self::summary or self::remarks)]"/>
 45    /// <summary>
 46    ///     <inheritdoc/>
 47    /// </summary>
 48    /// <remarks>
 49    ///     <inheritdoc cref="PartiallyIterativeConverter" path="/remarks"/>
 50    ///     <inheritdoc cref="IConverter.TreeToTrie(SuffixTreeNode)" path="/remarks"/>
 51    /// </remarks>
 52    public SuffixTrieNode TreeToTrie(SuffixTreeNode treeNode) =>
 3753        treeNode switch
 3754        {
 3755            SuffixTreeNode.Leaf(var leafStart) =>
 1856                new SuffixTrieNode.Leaf(leafStart),
 3757
 3758            SuffixTreeNode.Intermediate(var treeNodeChildren) =>
 1759                new SuffixTrieNode.Intermediate(new Dictionary<SuffixTrieEdge, SuffixTrieNode>(
 1760                    from treeChild in treeNodeChildren
 2461                    let expandedLastTrieNode = TreeToTrie(treeChild.Value)
 2262                    let expandedChild = IterativeExpand(treeChild.Key, expandedLastTrieNode)
 3963                    select KeyValuePair.Create(expandedChild.expandedTrieEdge, expandedChild.expandedTrieNode))),
 3764
 265            _ => throw new NotSupportedException($"{treeNode} of type {treeNode.GetType().Name} not supported")
 3766        };
 67}