private double EvaluateEdgeLength(
            CompoundGraph <object, IEdge <object> > compoundGraph,
            CompoundFDPLayoutAlgorithm <object, IEdge <object>, CompoundGraph <object, IEdge <object> > > algorithm,
            Dictionary <object, Size> sizes,
            double idealEdgeLength,
            double nestingFactor)
        {
            double edgeLengthError = 0.0;

            foreach (var edge in compoundGraph.Edges)
            {
                var uPos  = algorithm.VertexPositions[edge.Source];
                var vPos  = algorithm.VertexPositions[edge.Target];
                var uSize = sizes[edge.Source];
                var vSize = sizes[edge.Target];

                var uPoint = LayoutUtil.GetClippingPoint(uSize, uPos, vPos);
                var vPoint = LayoutUtil.GetClippingPoint(vSize, vPos, uPos);

                double length      = (uPoint - vPoint).Length;
                bool   isInterEdge = compoundGraph.GetParent(edge.Source) != compoundGraph.GetParent(edge.Target);
                var    iel         = isInterEdge
                              ? idealEdgeLength *
                                     (algorithm.LevelOfVertex(edge.Source) + algorithm.LevelOfVertex(edge.Target) + 1) *
                                     nestingFactor
                              : idealEdgeLength;
                double err = Math.Pow(length - iel, 2);
                edgeLengthError += err;
            }
            return(edgeLengthError);
        }
        private static double EvaluateEdgeLength(
            [NotNull] ICompoundGraph <object, IEdge <object> > compoundGraph,
            [NotNull] CompoundFDPLayoutAlgorithm <object, IEdge <object>, CompoundGraph <object, IEdge <object> > > algorithm,
            [NotNull] IReadOnlyDictionary <object, Size> verticesSizes,
            double idealEdgeLength,
            double nestingFactor)
        {
            double edgeLengthError = 0.0;

            foreach (IEdge <object> edge in compoundGraph.Edges)
            {
                Point uPos  = algorithm.VerticesPositions[edge.Source];
                Point vPos  = algorithm.VerticesPositions[edge.Target];
                Size  uSize = verticesSizes[edge.Source];
                Size  vSize = verticesSizes[edge.Target];

                Point uPoint = LayoutUtils.GetClippingPoint(uSize, uPos, vPos);
                Point vPoint = LayoutUtils.GetClippingPoint(vSize, vPos, uPos);

                double length      = (uPoint - vPoint).Length;
                bool   isInterEdge = compoundGraph.GetParent(edge.Source) != compoundGraph.GetParent(edge.Target);
                double iel         = isInterEdge
                              ? idealEdgeLength *
                                     (algorithm.LevelOfVertex(edge.Source) + algorithm.LevelOfVertex(edge.Target) + 1) *
                                     nestingFactor
                              : idealEdgeLength;
                double error = Math.Pow(length - iel, 2);
                edgeLengthError += error;
            }

            return(edgeLengthError);
        }