documentationfor yFiles for HTML 2.6

SpanningTree

Calculates a minimum spanning tree or forest for a graph.

Inheritance Hierarchy
SpanningTree

Remarks

Definitions

  • A spanning tree of an undirected connected graph is a subset of its edges that induce a tree that connects all nodes of the graph.
  • A minimum spanning tree of a weighted connected graph is a spanning tree whose edges have minimum overall cost among all spanning trees of that graph.

If the graph is not connected, the result is a (minimum) spanning forest instead, whose components are spanning trees.

Other Tree-Related Algorithms

yFiles for HTML supports a number of other algorithms and helpers related to trees:

  • FeedbackEdgeSet – finds edges that can be removed or reversed to make a graph into a tree
  • TreeAnalysis – analyzes directed trees and provides access to tree properties, for example, the root node, the set of leaf nodes or the depth of a node.

Examples

Calculating a spanning tree of the graph
// prepare the spanning tree detection algorithm
const algorithm = new SpanningTree()
// run the algorithm
const result = algorithm.run(graph)

// Remove the edges in the reduction
for (const edge of result.edges) {
  graph.setStyle(edge, spanningTreeEdgeStyle)
}

Type Details

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

See Also

Constructors

Properties

Methods