documentationfor yFiles for HTML 2.6

Finds all chains in a graph.

Inheritance Hierarchy
Chains

Remarks

A chain is a path of maximum length in which each internal node has degree 2.

The internal nodes on directed chains all have in-degree 1 and out-degree 1.

Other Path-Related Algorithms

yFiles for HTML supports a number of other algorithms related to paths in a graph:

  • Paths – finds all paths between a set of source and a set of target nodes
  • Cycle – finds a cycle if one exists
  • LongestPath – finds the longest path in the graph

Examples

Highlighting the edges along the chains
const result = new Chains({ directed: true }).run(graph)
result.chains.forEach((path) =>
  path.edges.forEach((edge) => graph.setStyle(edge, highlightEdgeStyle))
)
Highlighting all chains in a graph
// prepare the chain detection algorithm
const algorithm = new Chains()
// run the algorithm
const result = algorithm.run(graph)

// highlight the cycle
for (const edge of result.chains.flatMap((c) => c.edges)) {
  graph.setStyle(edge, highlightChainsStyle)
}

Type Details

yfiles module
view-layout-bridge
yfiles-umd modules
view-layout-bridge
Legacy UMD name
yfiles.analysis.Chains

See Also

Constructors

Properties

Methods