private static Cluster CreateCluster(IEnumerable <Node> nodes, double margin, string name = "") { var cluster = new Cluster(nodes.Where(n => !(n is Cluster))) { RectangularBoundary = new RectangularClusterBoundary { LeftMargin = margin, RightMargin = margin, BottomMargin = margin, TopMargin = margin }, BoundaryCurve = CurveFactory.CreateRectangle(1, 1, new Point()) }; cluster.CalculateBoundsFromChildren(0); cluster.UserData = name; var nc = nodes.Where(n => n is Cluster); foreach (var b in nc) { cluster.AddCluster((Cluster)b); } return(cluster); }