< Summary

Information
Class: MoreStructures.RecImmTrees.TreePathExtensions
Assembly: MoreStructures
File(s): /home/runner/work/MoreStructures/MoreStructures/MoreStructures/RecImmTrees/TreePathExtensions.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 37
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
Concat(...)100%1100%
Append(...)100%1100%

File(s)

/home/runner/work/MoreStructures/MoreStructures/MoreStructures/RecImmTrees/TreePathExtensions.cs

#LineLine coverage
 1namespace MoreStructures.RecImmTrees;
 2
 3/// <summary>
 4/// Extension methods for <see cref="TreePath{TEdge, TNode}"/>.
 5/// </summary>
 6public static class TreePathExtensions
 7{
 8    /// <summary>
 9    /// Builds a new path of nodes, appending the nodes of the second path to the first path.
 10    /// </summary>
 11    /// <param name="first">The path, to append nodes to.</param>
 12    /// <param name="second">The path, whose nodes have to be appended.</param>
 13    /// <returns>A new path, whose nodes are the concatenation of the nodes of the two paths.</returns>
 14    public static TreePath<TEdge, TNode> Concat<TEdge, TNode>(
 15        this TreePath<TEdge, TNode> first,
 16        TreePath<TEdge, TNode> second)
 17        where TEdge : IRecImmDictIndexedTreeEdge<TEdge, TNode>
 18        where TNode : IRecImmDictIndexedTreeNode<TEdge, TNode> =>
 3519        new(first.PathNodes.Concat(second.PathNodes));
 20
 21    /// <summary>
 22    /// Append the provided node with its incoming edge to the provided path, bulding a new path.
 23    /// </summary>
 24    /// <param name="path">The path, to appended the node and the edge to.</param>
 25    /// <param name="edge">The edge, pointing to the node to be appended.</param>
 26    /// <param name="node">The node to be appended.</param>
 27    /// <returns>
 28    /// A new path, whose nodes are the concatenation of the nodes of the provided path and the one appended.
 29    /// </returns>
 30    public static TreePath<TEdge, TNode> Append<TEdge, TNode>(
 31        this TreePath<TEdge, TNode> path,
 32        TEdge edge,
 33        TNode node)
 34        where TEdge : IRecImmDictIndexedTreeEdge<TEdge, TNode>
 35        where TNode : IRecImmDictIndexedTreeNode<TEdge, TNode> =>
 136        new(path.PathNodes.Concat(Enumerable.Repeat(KeyValuePair.Create(edge, node), 1)));
 37}