/// <summary>
 /// Verifies that the edge's label is near the edge.
 /// </summary>
 private static void VerifyLabelIsNearEdges(Edge edge)
 {
     Label label = edge.Label;
     if (label != null)
     {
         Rectangle labelBox = label.BoundingBox;
         Point[] edgePoints = edge.GetPoints();
         Point[] labelPoints = new[] { labelBox.Center, labelBox.LeftTop, labelBox.LeftBottom, labelBox.RightBottom, labelBox.RightTop };
         
         if (!edgePoints.Any(p => labelBox.Contains(p)))
         {
             // If the edge doesn't intersect the label, check that the label is at least nearby.
             // 10 was chosen as the distance tolerance since it is fairly small and passes on pretty much every diagram I tested.
             double closestDistance = GetClosestDistance(edgePoints, labelPoints);
             Assert.IsTrue(closestDistance < 10, "The label was placed greater than 10 units from the edge.");
         }
     }
 }