< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Radius()0%6200%
Recenter()0%2100%
Merge(...)0%12300%

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 {
 010    get => _centroid;
 011    set => _centroid = value;
 12  }
 13
 014  public int Size => ActiveSubHierarchicals.Count();
 015  public bool IsEmpty => Size == 0;
 16
 017  public float Radius() {
 018    if (IsEmpty) {
 019      return 0;
 20    }
 021    return ActiveSubHierarchicals.DefaultIfEmpty().Max(
 22        subHierarchical =>
 023            subHierarchical == null ? 0 : Vector3.Distance(Centroid, subHierarchical.Position));
 024  }
 25
 026  public void Recenter() {
 027    Centroid = Position;
 028  }
 29
 30  // Merging with another cluster does not update the centroid of the current cluster.
 031  public void Merge(Cluster cluster) {
 032    foreach (var subHierarchical in cluster.SubHierarchicals) {
 033      AddSubHierarchical(subHierarchical);
 034    }
 035  }
 36}