// Copyright (c) 2026 The elk-go Authors.//// This program and the accompanying materials are made available under the// terms of the Eclipse Public License 2.0 which is available at// https://www.eclipse.org/legal/epl-2.0.//// SPDX-License-Identifier: EPL-2.0package elkimport ()// Layout computes layout in place. Like elkjs, it preserves the input graph's// element and slice order and adds computed shape and edge-route fields.func ( *Graph) error { , := defaultRegistries() := core.NewCodec() , := .Import()if != nil {returnfmt.Errorf("import ELK graph: %w", ) }if := core.NewEngine(, ).Layout(); != nil {returnfmt.Errorf("layout ELK graph: %w", ) }if := .TransferLayout(); != nil {returnfmt.Errorf("export ELK layout: %w", ) }returnnil}// LayoutJSON is the byte-oriented equivalent of Layout.func ( []byte) ([]byte, error) { := json.NewDecoder(bytes.NewReader()) .UseNumber()vargraphjson.Graphif := .Decode(&); != nil {returnnil, fmt.Errorf("decode ELK graph: %w", ) }varanyif := .Decode(&); != io.EOF {if == nil {returnnil, fmt.Errorf("decode ELK graph: unexpected trailing JSON value") }returnnil, fmt.Errorf("decode ELK graph: %w", ) }if := Layout(&); != nil {returnnil, } , := json.Marshal(&)if != nil {returnnil, fmt.Errorf("encode ELK graph: %w", ) }return , nil}// defaultRegistries is the single integration point for native providers.// Algorithm packages register D2's eleven ELK.js 0.12.0 provider IDs and the// official option metadata here. The executable compatibility contract is// D2's documented profile, not every expert option combination.func defaultRegistries() (*core.OptionRegistry, *core.AlgorithmRegistry) { := core.NewOptionRegistry()builtins.RegisterOptions() := core.NewAlgorithmRegistry()if := builtins.Register(); != nil {panic() }return , }
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.