From 95e0aaedd9e8b52746de2283f4486e71c8967e79 Mon Sep 17 00:00:00 2001 From: Mayank Mohapatra <125661248+Mayank77maruti@users.noreply.github.com> Date: Sat, 8 Mar 2025 11:02:38 +0000 Subject: [PATCH] try --- d2layouts/d2cycle/layout.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/d2layouts/d2cycle/layout.go b/d2layouts/d2cycle/layout.go index 73f663551..fbe855391 100644 --- a/d2layouts/d2cycle/layout.go +++ b/d2layouts/d2cycle/layout.go @@ -39,7 +39,12 @@ func Layout(ctx context.Context, g *d2graph.Graph, layout d2graph.LayoutGraph) e return nil } +// calculateRadius now guards against a division-by-zero error when there is only one object. func calculateRadius(objects []*d2graph.Object) float64 { + if len(objects) < 2 { + // When there is a single object, we can simply use MIN_RADIUS. + return MIN_RADIUS + } numObjects := float64(len(objects)) maxSize := 0.0 for _, obj := range objects {