StellaOps.ElkSharp

Layered layout of directed graphs: layer assignment, node ordering and placement, and edge routing. Lays out workflow diagrams.

library
Component
Workflow
Licence
BUSL-1.1 (Workflow licence)
Target framework
net10.0
Latest release
1.0.1-20261118T121708Z

Install

dotnet add package StellaOps.ElkSharp --version 1.0.1-20261118T121708Z

Namespaces

NamespaceTypes
StellaOps.ElkSharp20

namespace StellaOps.ElkSharp

TypeKindDescription
EdgeRefinementOptionsrecordSettings of the pass that reroutes problem edges after the first routing.
ElkEdgerecordAn edge of a graph to lay out.
ElkEdgeSectionrecordA routed section of an edge.
ElkGraphrecordA graph to lay out: nodes and edges.
ElkLayoutDirectionenumThe direction of the layers.
ElkLayoutEffortenumHow hard the layout works on node order and placement.
ElkLayoutOptionsrecordSettings of an ElkSharp layered layout.
ElkLayoutResultrecordA laid-out graph: positioned nodes and routed edges.
ElkNoderecordA node of a graph to lay out.
ElkPointrecordA point of a laid-out graph.
ElkPortrecordA port of a node to lay out.
ElkPositionedNoderecordA positioned node.
ElkPositionedPortrecordA positioned port.
ElkRoutedEdgerecordA routed edge.
ElkSharpLayeredLayoutEngineclassThe ElkSharp layered layout engine.
ElkSharpSourceAnalyzerclassCounts the constructs of a compiled ELK JavaScript source.
ElkSharpSourceProfilerecordThe construct counts of a compiled ELK JavaScript source.
IElkLayoutEngineinterfaceLays out graphs.
IterativeRoutingModeenumThe strategy of the iterative edge routing.
IterativeRoutingOptionsrecordSettings of the iterative edge routing.

record EdgeRefinementOptions

public sealed record EdgeRefinementOptions

Settings of the pass that reroutes problem edges after the first routing.

Members

MemberKindSummary
EdgeRefinementOptions()constructorCreates an instance of EdgeRefinementOptions.
BaseObstacleMarginpropertyThe margin kept around nodes, at least 8 layout units.
EnabledpropertyWhether edges are refined after routing; when not set, on with ElkLayoutEffort.Besteffort and off otherwise.
MaxGlobalPassespropertyThe refinement passes over the whole graph; not negative.
MaxProblemEdgesPerPasspropertyThe problem edges refined in one pass, at least 1.
MaxTrialsPerProblemEdgepropertyThe reroute trials per problem edge, at least 1.
SoftObstacleClearancepropertyThe clearance kept from soft obstacles, at least 8 layout units.
SoftObstacleWeightpropertyThe weight of soft obstacles in route costs; not negative.

constructor EdgeRefinementOptions() #

public EdgeRefinementOptions()

Creates an instance of EdgeRefinementOptions.

property BaseObstacleMargin #

public double BaseObstacleMargin { get; init; }

The margin kept around nodes, at least 8 layout units. The default is 18.

property Enabled #

public bool? Enabled { get; init; }

Whether edges are refined after routing; when not set, on with ElkLayoutEffort.Besteffort and off otherwise.

property MaxGlobalPasses #

public int MaxGlobalPasses { get; init; }

The refinement passes over the whole graph; not negative. The default is 2.

property MaxProblemEdgesPerPass #

public int MaxProblemEdgesPerPass { get; init; }

The problem edges refined in one pass, at least 1. The default is 12.

property MaxTrialsPerProblemEdge #

public int MaxTrialsPerProblemEdge { get; init; }

The reroute trials per problem edge, at least 1. The default is 4.

property SoftObstacleClearance #

public double SoftObstacleClearance { get; init; }

The clearance kept from soft obstacles, at least 8 layout units. The default is 14.

property SoftObstacleWeight #

public double SoftObstacleWeight { get; init; }

The weight of soft obstacles in route costs; not negative. The default is 0.4.

record ElkEdge

public sealed record ElkEdge

An edge of a graph to lay out.

Members

MemberKindSummary
ElkEdge()constructorCreates an instance of ElkEdge.
IdpropertyThe edge identifier.
KindpropertyThe edge kind.
LabelpropertyThe label.
SourceNodeIdpropertyThe source node.
SourcePortIdpropertyThe source port, when the edge leaves a port.
TargetNodeIdpropertyThe target node.
TargetPortIdpropertyThe target port, when the edge enters a port.

constructor ElkEdge() #

public ElkEdge()

Creates an instance of ElkEdge.

property Id #

public required string Id { get; init; }

The edge identifier.

property Kind #

public string? Kind { get; init; }

The edge kind.

property Label #

public string? Label { get; init; }

The label.

property SourceNodeId #

public required string SourceNodeId { get; init; }

The source node.

property SourcePortId #

public string? SourcePortId { get; init; }

The source port, when the edge leaves a port.

property TargetNodeId #

public required string TargetNodeId { get; init; }

The target node.

property TargetPortId #

public string? TargetPortId { get; init; }

The target port, when the edge enters a port.

record ElkEdgeSection

public sealed record ElkEdgeSection

A routed section of an edge.

Members

MemberKindSummary
ElkEdgeSection()constructorCreates an instance of ElkEdgeSection.
BendPointspropertyThe bends between them.
EndPointpropertyWhere the section ends.
StartPointpropertyWhere the section starts.

constructor ElkEdgeSection() #

public ElkEdgeSection()

Creates an instance of ElkEdgeSection.

property BendPoints #

public IReadOnlyCollection<ElkPoint> BendPoints { get; init; }

The bends between them.

property EndPoint #

public required ElkPoint EndPoint { get; init; }

Where the section ends.

property StartPoint #

public required ElkPoint StartPoint { get; init; }

Where the section starts.

record ElkGraph

public sealed record ElkGraph

A graph to lay out: nodes and edges.

Members

MemberKindSummary
ElkGraph()constructorCreates an instance of ElkGraph.
EdgespropertyThe edges.
IdpropertyThe graph identifier.
NodespropertyThe nodes.

constructor ElkGraph() #

public ElkGraph()

Creates an instance of ElkGraph.

property Edges #

public required IReadOnlyCollection<ElkEdge> Edges { get; init; }

The edges.

property Id #

public required string Id { get; init; }

The graph identifier.

property Nodes #

public required IReadOnlyCollection<ElkNode> Nodes { get; init; }

The nodes.

enum ElkLayoutDirection

public enum ElkLayoutDirection

The direction of the layers.

ValueDescription
TopToBottom = 0From top to bottom.
LeftToRight = 1From left to right.

enum ElkLayoutEffort

public enum ElkLayoutEffort

How hard the layout works on node order and placement.

ValueDescription
Draft = 0The fewest ordering and placement iterations: the fastest layout.
Balanced = 1A middle number of ordering and placement iterations.
Best = 2The most ordering and placement iterations; edge refinement and iterative routing are on unless their options turn them off. The default.

record ElkLayoutOptions

public sealed record ElkLayoutOptions

Settings of an ElkSharp layered layout.

Members

MemberKindSummary
ElkLayoutOptions()constructorCreates an instance of ElkLayoutOptions.
CompoundHeaderHeightpropertyThe height of a compound node’s header, in layout units.
CompoundPaddingpropertyThe padding inside a compound node, in layout units.
DirectionpropertyThe direction of the layers.
EdgeRefinementpropertyThe edge refinement pass; the defaults apply when not set.
EffortpropertyHow much work the layout spends on quality.
IterativeRoutingpropertyThe iterative edge routing; the defaults apply when not set.
LayerSpacingpropertyThe space between layers, in layout units.
NodeSpacingpropertyThe space between nodes of one layer, in layout units.
OrderingIterationspropertyThe node ordering iterations, at least 2; when not set, derived from the graph size and the effort.
PlacementIterationspropertyThe node placement iterations, at least 1; when not set, derived from the graph size and the effort.

constructor ElkLayoutOptions() #

public ElkLayoutOptions()

Creates an instance of ElkLayoutOptions.

property CompoundHeaderHeight #

public double CompoundHeaderHeight { get; init; }

The height of a compound node’s header, in layout units. The default is 28.

property CompoundPadding #

public double CompoundPadding { get; init; }

The padding inside a compound node, in layout units. The default is 30.

property Direction #

public ElkLayoutDirection Direction { get; init; }

The direction of the layers. The default is ElkLayoutDirection.LeftToRight.

property EdgeRefinement #

public EdgeRefinementOptions? EdgeRefinement { get; init; }

The edge refinement pass; the defaults apply when not set.

property Effort #

public ElkLayoutEffort Effort { get; init; }

How much work the layout spends on quality. The default is ElkLayoutEffort.Best.

property IterativeRouting #

public IterativeRoutingOptions? IterativeRouting { get; init; }

The iterative edge routing; the defaults apply when not set.

property LayerSpacing #

public double LayerSpacing { get; init; }

The space between layers, in layout units. The default is 80.

property NodeSpacing #

public double NodeSpacing { get; init; }

The space between nodes of one layer, in layout units. The default is 40.

property OrderingIterations #

public int? OrderingIterations { get; init; }

The node ordering iterations, at least 2; when not set, derived from the graph size and the effort.

property PlacementIterations #

public int? PlacementIterations { get; init; }

The node placement iterations, at least 1; when not set, derived from the graph size and the effort.

record ElkLayoutResult

public sealed record ElkLayoutResult

A laid-out graph: positioned nodes and routed edges.

Members

MemberKindSummary
ElkLayoutResult()constructorCreates an instance of ElkLayoutResult.
EdgespropertyThe routed edges.
GraphIdpropertyThe graph identifier.
NodespropertyThe positioned nodes.

constructor ElkLayoutResult() #

public ElkLayoutResult()

Creates an instance of ElkLayoutResult.

property Edges #

public required IReadOnlyCollection<ElkRoutedEdge> Edges { get; init; }

The routed edges.

property GraphId #

public required string GraphId { get; init; }

The graph identifier.

property Nodes #

public required IReadOnlyCollection<ElkPositionedNode> Nodes { get; init; }

The positioned nodes.

record ElkNode

public sealed record ElkNode

A node of a graph to lay out.

Members

MemberKindSummary
ElkNode()constructorCreates an instance of ElkNode.
HeightpropertyThe node height.
IconKeypropertyThe icon of the node.
IdpropertyThe node identifier.
KindpropertyThe node kind.
LabelpropertyThe label.
ParentNodeIdpropertyThe node that contains this one, when it is nested.
PortspropertyThe ports.
RoutepropertyThe route of a task node.
SemanticKeypropertyThe name of what the node stands for.
SemanticTypepropertyWhat the node stands for.
TaskTypepropertyThe task type of a task node.
WidthpropertyThe node width.

constructor ElkNode() #

public ElkNode()

Creates an instance of ElkNode.

property Height #

public double Height { get; init; }

The node height.

property IconKey #

public string? IconKey { get; init; }

The icon of the node.

property Id #

public required string Id { get; init; }

The node identifier.

property Kind #

public required string Kind { get; init; }

The node kind.

property Label #

public required string Label { get; init; }

The label.

property ParentNodeId #

public string? ParentNodeId { get; init; }

The node that contains this one, when it is nested.

property Ports #

public IReadOnlyCollection<ElkPort> Ports { get; init; }

The ports.

property Route #

public string? Route { get; init; }

The route of a task node.

property SemanticKey #

public string? SemanticKey { get; init; }

The name of what the node stands for.

property SemanticType #

public string? SemanticType { get; init; }

What the node stands for.

property TaskType #

public string? TaskType { get; init; }

The task type of a task node.

property Width #

public double Width { get; init; }

The node width.

record ElkPoint

public sealed record ElkPoint

A point of a laid-out graph.

Members

MemberKindSummary
ElkPoint()constructorCreates an instance of ElkPoint.
XpropertyThe horizontal position.
YpropertyThe vertical position.

constructor ElkPoint() #

public ElkPoint()

Creates an instance of ElkPoint.

property X #

public required double X { get; init; }

The horizontal position.

property Y #

public required double Y { get; init; }

The vertical position.

record ElkPort

public sealed record ElkPort

A port of a node to lay out.

Members

MemberKindSummary
ElkPort()constructorCreates an instance of ElkPort.
HeightpropertyThe port height.
IdpropertyThe port identifier.
SidepropertyThe side of the node the port is on.
WidthpropertyThe port width.

constructor ElkPort() #

public ElkPort()

Creates an instance of ElkPort.

property Height #

public double Height { get; init; }

The port height.

property Id #

public required string Id { get; init; }

The port identifier.

property Side #

public string? Side { get; init; }

The side of the node the port is on.

property Width #

public double Width { get; init; }

The port width.

record ElkPositionedNode

public sealed record ElkPositionedNode

A positioned node.

Members

MemberKindSummary
ElkPositionedNode()constructorCreates an instance of ElkPositionedNode.
HeightpropertyThe node height.
IconKeypropertyThe icon of the node.
IdpropertyThe node identifier.
KindpropertyThe node kind.
LabelpropertyThe label.
ParentNodeIdpropertyThe node that contains this one, when it is nested.
PortspropertyThe positioned ports.
RoutepropertyThe route of a task node.
SemanticKeypropertyThe name of what the node stands for.
SemanticTypepropertyWhat the node stands for.
TaskTypepropertyThe task type of a task node.
WidthpropertyThe node width.
XpropertyThe left edge of the node.
YpropertyThe top edge of the node.

constructor ElkPositionedNode() #

public ElkPositionedNode()

Creates an instance of ElkPositionedNode.

property Height #

public double Height { get; init; }

The node height.

property IconKey #

public string? IconKey { get; init; }

The icon of the node.

property Id #

public required string Id { get; init; }

The node identifier.

property Kind #

public required string Kind { get; init; }

The node kind.

property Label #

public required string Label { get; init; }

The label.

property ParentNodeId #

public string? ParentNodeId { get; init; }

The node that contains this one, when it is nested.

property Ports #

public IReadOnlyCollection<ElkPositionedPort> Ports { get; init; }

The positioned ports.

property Route #

public string? Route { get; init; }

The route of a task node.

property SemanticKey #

public string? SemanticKey { get; init; }

The name of what the node stands for.

property SemanticType #

public string? SemanticType { get; init; }

What the node stands for.

property TaskType #

public string? TaskType { get; init; }

The task type of a task node.

property Width #

public double Width { get; init; }

The node width.

property X #

public double X { get; init; }

The left edge of the node.

property Y #

public double Y { get; init; }

The top edge of the node.

record ElkPositionedPort

public sealed record ElkPositionedPort

A positioned port.

Members

MemberKindSummary
ElkPositionedPort()constructorCreates an instance of ElkPositionedPort.
HeightpropertyThe port height.
IdpropertyThe port identifier.
SidepropertyThe side of the node the port is on.
WidthpropertyThe port width.
XpropertyThe left edge of the port.
YpropertyThe top edge of the port.

constructor ElkPositionedPort() #

public ElkPositionedPort()

Creates an instance of ElkPositionedPort.

property Height #

public double Height { get; init; }

The port height.

property Id #

public required string Id { get; init; }

The port identifier.

property Side #

public string? Side { get; init; }

The side of the node the port is on.

property Width #

public double Width { get; init; }

The port width.

property X #

public double X { get; init; }

The left edge of the port.

property Y #

public double Y { get; init; }

The top edge of the port.

record ElkRoutedEdge

public sealed record ElkRoutedEdge

A routed edge.

Members

MemberKindSummary
ElkRoutedEdge()constructorCreates an instance of ElkRoutedEdge.
IdpropertyThe edge identifier.
KindpropertyThe edge kind.
LabelpropertyThe label.
SectionspropertyThe routed sections.
SourceNodeIdpropertyThe source node.
SourcePortIdpropertyThe source port, when the edge leaves a port.
TargetNodeIdpropertyThe target node.
TargetPortIdpropertyThe target port, when the edge enters a port.

constructor ElkRoutedEdge() #

public ElkRoutedEdge()

Creates an instance of ElkRoutedEdge.

property Id #

public required string Id { get; init; }

The edge identifier.

property Kind #

public string? Kind { get; init; }

The edge kind.

property Label #

public string? Label { get; init; }

The label.

property Sections #

public IReadOnlyCollection<ElkEdgeSection> Sections { get; init; }

The routed sections.

property SourceNodeId #

public required string SourceNodeId { get; init; }

The source node.

property SourcePortId #

public string? SourcePortId { get; init; }

The source port, when the edge leaves a port.

property TargetNodeId #

public required string TargetNodeId { get; init; }

The target node.

property TargetPortId #

public string? TargetPortId { get; init; }

The target port, when the edge enters a port.

class ElkSharpLayeredLayoutEngine

public sealed class ElkSharpLayeredLayoutEngine : IElkLayoutEngine

The ElkSharp layered layout engine.

Members

MemberKindSummary
ElkSharpLayeredLayoutEngine()constructorCreates an instance of ElkSharpLayeredLayoutEngine.
LayoutAsync(ElkGraph, ElkLayoutOptions, CancellationToken)methodLays out a graph.

constructor ElkSharpLayeredLayoutEngine() #

public ElkSharpLayeredLayoutEngine()

Creates an instance of ElkSharpLayeredLayoutEngine.

method LayoutAsync(ElkGraph, ElkLayoutOptions, CancellationToken) #

public Task<ElkLayoutResult> LayoutAsync(ElkGraph graph, ElkLayoutOptions? options = null, CancellationToken cancellationToken = default)

Lays out a graph.

Parameters

  • graph: The graph.
  • options: The layout options; the defaults when not set.
  • cancellationToken: Cancels the layout.

Returns

The positioned nodes and routed edges.

class ElkSharpSourceAnalyzer

public static class ElkSharpSourceAnalyzer

Counts the constructs of a compiled ELK JavaScript source.

Members

MemberKindSummary
Analyze(string, string)methodProfiles source text.
AnalyzeFileAsync(string, CancellationToken)methodProfiles a source file.

method Analyze(string, string) #

public static ElkSharpSourceProfile Analyze(string sourceName, string sourceText)

Profiles source text.

Parameters

  • sourceName: The source name.
  • sourceText: The source text.

Returns

The profile.

method AnalyzeFileAsync(string, CancellationToken) #

public static Task<ElkSharpSourceProfile> AnalyzeFileAsync(string path, CancellationToken cancellationToken = default)

Profiles a source file.

Parameters

  • path: The file.
  • cancellationToken: Cancels the read.

Returns

The profile.

record ElkSharpSourceProfile

public sealed record ElkSharpSourceProfile

The construct counts of a compiled ELK JavaScript source.

Members

MemberKindSummary
ElkSharpSourceProfile()constructorCreates an instance of ElkSharpSourceProfile.
CharacterCountpropertyThe characters.
CreateForClassCountpropertyThe createForClass calls.
DefineClassCountpropertyThe defineClass calls.
FunctionCountpropertyThe function declarations.
InternConstantCountpropertyThe $intern_ constants.
LayoutCommandCountpropertyThe layout commands.
LineCountpropertyThe lines.
RegisterAlgorithmCountpropertyThe registerLayoutAlgorithms calls.
SourceNamepropertyThe source name.

constructor ElkSharpSourceProfile() #

public ElkSharpSourceProfile()

Creates an instance of ElkSharpSourceProfile.

property CharacterCount #

public int CharacterCount { get; init; }

The characters.

property CreateForClassCount #

public int CreateForClassCount { get; init; }

The createForClass calls.

property DefineClassCount #

public int DefineClassCount { get; init; }

The defineClass calls.

property FunctionCount #

public int FunctionCount { get; init; }

The function declarations.

property InternConstantCount #

public int InternConstantCount { get; init; }

The $intern_ constants.

property LayoutCommandCount #

public int LayoutCommandCount { get; init; }

The layout commands.

property LineCount #

public int LineCount { get; init; }

The lines.

property RegisterAlgorithmCount #

public int RegisterAlgorithmCount { get; init; }

The registerLayoutAlgorithms calls.

property SourceName #

public required string SourceName { get; init; }

The source name.

interface IElkLayoutEngine

public interface IElkLayoutEngine

Lays out graphs.

Members

MemberKindSummary
LayoutAsync(ElkGraph, ElkLayoutOptions, CancellationToken)methodLays out a graph.

method LayoutAsync(ElkGraph, ElkLayoutOptions, CancellationToken) #

Task<ElkLayoutResult> LayoutAsync(ElkGraph graph, ElkLayoutOptions? options = null, CancellationToken cancellationToken = default)

Lays out a graph.

Parameters

  • graph: The graph.
  • options: The layout options; the defaults when not set.
  • cancellationToken: Cancels the layout.

Returns

The positioned nodes and routed edges.

enum IterativeRoutingMode

public enum IterativeRoutingMode

The strategy of the iterative edge routing.

ValueDescription
LegacyMultiStrategy = 0The multi-strategy routing, the default.
HybridDeterministic = 1The deterministic hybrid routing.

record IterativeRoutingOptions

public sealed record IterativeRoutingOptions

Settings of the iterative edge routing.

Members

MemberKindSummary
IterativeRoutingOptions()constructorCreates an instance of IterativeRoutingOptions.
EnabledpropertyWhether edges are routed iteratively; when not set, on with ElkLayoutEffort.Besteffort and off otherwise.
MaxAdaptationsPerStrategypropertyThe adaptations tried per strategy, from 1 to 100.
MaxParallelRepairBuildspropertyThe repair builds that run in parallel, from 1 to the processor count.
MaxRepairWavespropertyThe repair waves, from 1 to 12.
ModepropertyThe iterative routing strategy.
RequiredValidSolutionspropertyThe valid-solution budget of the iterative router, at least 1.

constructor IterativeRoutingOptions() #

public IterativeRoutingOptions()

Creates an instance of IterativeRoutingOptions.

property Enabled #

public bool? Enabled { get; init; }

Whether edges are routed iteratively; when not set, on with ElkLayoutEffort.Besteffort and off otherwise.

property MaxAdaptationsPerStrategy #

public int MaxAdaptationsPerStrategy { get; init; }

The adaptations tried per strategy, from 1 to 100. The default is 100.

property MaxParallelRepairBuilds #

public int MaxParallelRepairBuilds { get; init; }

The repair builds that run in parallel, from 1 to the processor count. The default is 4.

property MaxRepairWaves #

public int MaxRepairWaves { get; init; }

The repair waves, from 1 to 12. The default is 4.

property Mode #

public IterativeRoutingMode Mode { get; init; }

The iterative routing strategy. The default is IterativeRoutingMode.LegacyMultiStrategy.

property RequiredValidSolutions #

public int RequiredValidSolutions { get; init; }

The valid-solution budget of the iterative router, at least 1. The default is 10.