private static H3.Cell.Edge[] CullValence2Edges( H3.Cell.Edge[] edges ) { List<H3.Cell.Edge> needRemoval = new List<H3.Cell.Edge>(); // Info we'll need to remove dangling edges. Dictionary<Vector3D, int> vertexCounts = new Dictionary<Vector3D, int>(); foreach( H3.Cell.Edge edge in edges ) { CheckAndAdd( vertexCounts, edge.Start ); CheckAndAdd( vertexCounts, edge.End ); } foreach( H3.Cell.Edge e in edges ) { if( vertexCounts[e.Start] == 2 || vertexCounts[e.End] == 2 ) { needRemoval.Add( e ); } } return edges.Except( needRemoval ).ToArray(); }