// Copyright (c) 2011, 2020 Kiel University and others.
// Copyright (c) 2015, 2020 Kiel University and others.
//
// 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.0

package force

import (
	

	
	
	
)

type Provider struct{}

func ( *core.AlgorithmRegistry) error {
	return .Register(core.AlgorithmData{
		ID:       "org.eclipse.elk.force",
		Features: core.FeatureMultiEdges | core.FeatureEdgeLabels,
		Create:   func() core.LayoutProvider { return &Provider{} },
		KnownOptions: []string{
			Priority.ID,
			SpacingNodeNode.ID,
			SpacingEdgeLabel.ID,
			AspectRatio.ID,
			RandomSeed.ID,
			SeparateConnectedComponents.ID,
			Padding.ID,
			Interactive.ID,
			core.PortConstraints.ID,
			EdgeLabelsInline.ID,
			OmitNodeMicroLayout.ID,
			"org.eclipse.elk.nodeSize.fixedGraphSize",
			"org.eclipse.elk.nodeSize.options",
			core.NodeSizeConstraints.ID,
			"org.eclipse.elk.nodeLabels.placement",
			"org.eclipse.elk.portLabels.placement",
			Model.ID,
			Temperature.ID,
			Iterations.ID,
			Repulsion.ID,
			RepulsivePower.ID,
			core.TopdownLayout.ID,
			core.TopdownScaleFactor.ID,
			core.TopdownHierarchicalNodeWidth.ID,
			core.TopdownHierarchicalNodeAspectRatio.ID,
			core.TopdownNodeType.ID,
		},
	})
}

func (*Provider) ( *graph.Model,  graph.NodeID,  core.ProgressMonitor) error {
	if !graph.Get(&.Node().Properties, OmitNodeMicroLayout) {
		nodespacing.CalculateLabelAndNodeSizes(, , nil)
	}
	 := NewImporter(, )
	,  := .ImportGraph()
	if  != nil {
		return 
	}
	 := Split()
	for ,  := range  {
		var  forceModel
		switch .Model {
		case ModelEades:
			 = &eadesModel{}
		case ModelFruchtermanReingold:
			 = &fruchtermanReingoldModel{}
		default:
			return fmt.Errorf("unknown force model %q", .Model)
		}
		.layout(, .Subtask(1/float64(len())))
	}
	.ApplyLayout(Recombine())
	return nil
}

// InitialLayout runs the exact force initialization used by ELK Stress when
// interactive mode is disabled. It is exported only to the sibling stress
// package within this module.
func ( *graph.Model,  graph.NodeID,  core.ProgressMonitor) error {
	return (&Provider{}).Layout(, , )
}