Layout Data
The LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> used to specify custom data input for layout algorithms has become generic. It can no longer only be applied in conjunction with IGraph but also with LayoutGraph. This change means that the classes now have several generic type arguments that describe the type of items in the graph. See for example HierarchicalLayoutData.
Migrate existing usages
Instead of directly instantiating the data, you can now use the new factory methods on the algorithm instance, for example, createLayoutData.
const iGraph = new Graph()
const hierarchicalLayout = new HierarchicalLayout()
// create layout data for IGraph using factory method
const data = hierarchicalLayout.createLayoutData()
// ... and example usage of the created data
data.incrementalNodes.predicate = (iNode) => iNode.labels.size > 0
iGraph.applyLayout(hierarchicalLayout, data)
const iGraph = new Graph()
const hierarchicalLayout = new HierarchicalLayout()
// create layout data for IGraph using factory method
const data = hierarchicalLayout.createLayoutData()
// ... and example usage of the created data
data.incrementalNodes.predicate = (iNode: INode) =>
iNode.labels.size > 0
iGraph.applyLayout(hierarchicalLayout, data)
Using the creation methods is often more convenient. However, creating the layout data via the constructor is still possible.
// create layout data for IGraph using constructor
const data = new HierarchicalLayoutData()
// create layout data for IGraph using constructor
const data = new HierarchicalLayoutData<
INode,
IEdge,
IModelItem,
ILabel,
ILabel
>()
You can now use the layout data when working with LayoutGraph in the same way.
const layoutGraph = new LayoutGraph()
const hierarchicalLayout = new HierarchicalLayout()
// create layout data for layoutGraph using factory method
const data = hierarchicalLayout.createLayoutData(layoutGraph)
// ... and example usage of the created data
data.incrementalNodes.predicate = (node) => node.labels.size > 0
layoutGraph.applyLayout(hierarchicalLayout, data)
const layoutGraph = new LayoutGraph()
const hierarchicalLayout = new HierarchicalLayout()
// create layout data for layoutGraph using factory method
const data = hierarchicalLayout.createLayoutData(layoutGraph)
// ... and example usage of the created data
data.incrementalNodes.predicate = (node: LayoutNode) =>
node.labels.size > 0
layoutGraph.applyLayout(hierarchicalLayout, data)
Further changes
- Settings related to ports are now all grouped within a sub-data structure. This structure is a top-level property on the respective layout data. For example, see HierarchicalLayoutData<TNode, TEdge, TNodeEdge, TNodeLabel, TEdgeLabel>.ports.
- Layout data properties that are not intended for user input but provide an output or result now include "Result" as a suffix. For example, see layerIndicesResult.