< Summary

Class:Cluster
Assembly:bamlab.micromissiles
File(s):/github/workspace/Assets/Scripts/Algorithms/Clustering/Cluster.cs
Covered lines:18
Uncovered lines:0
Coverable lines:18
Total lines:36
Line coverage:100% (18 of 18)
Covered branches:0
Total branches:0
Covered methods:7
Total methods:7
Method coverage:100% (7 of 7)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Radius()0%220100%
Recenter()0%110100%
Merge(...)0%330100%

File(s)

/github/workspace/Assets/Scripts/Algorithms/Clustering/Cluster.cs

#LineLine coverage
 1using System.Linq;
 2using UnityEngine;
 3
 4// The cluster represents a collection of hierarchical objects.
 5public class Cluster : HierarchicalBase {
 6  [SerializeField]
 7  private Vector3 _centroid;
 8
 9  public Vector3 Centroid {
 43510    get => _centroid;
 9411    set => _centroid = value;
 12  }
 13
 13014  public int Size => ActiveSubHierarchicals.Count();
 5915  public bool IsEmpty => Size == 0;
 16
 2017  public float Radius() {
 2118    if (IsEmpty) {
 119      return 0;
 20    }
 1921    return ActiveSubHierarchicals.DefaultIfEmpty().Max(
 22        subHierarchical =>
 4223            subHierarchical == null ? 0 : Vector3.Distance(Centroid, subHierarchical.Position));
 2024  }
 25
 5126  public void Recenter() {
 5127    Centroid = Position;
 5128  }
 29
 30  // Merging with another cluster does not update the centroid of the current cluster.
 731  public void Merge(Cluster cluster) {
 9932    foreach (var subHierarchical in cluster.SubHierarchicals) {
 2633      AddSubHierarchical(subHierarchical);
 2634    }
 735  }
 36}