documentationfor yFiles for HTML 2.6

TreeSubstructures

Detects SubstructureItemss that represent isolated trees in the specified graph.

Inheritance Hierarchy
TreeSubstructures

Remarks

The root of a tree is the only node which may have non-tree edges. Furthermore, a tree only consists of elements with the same nodeTypes.

The edgeDirectedness is considered as follows: A substructure is only identified as such if all edges are either undirected or consistently directed with respect to the specified directedness.

  • A directedness value of 1 indicates that the edge is considered to be directed from source to target.
  • A directedness value of -1 indicates that the edge is considered to be directed from target to source.
  • A directedness value of 0 indicates that the edge is considered to be undirected.

Examples

Finding the trees in a graph
// prepare the tree detection algorithm
const algorithm = new TreeSubstructures()
// run the algorithm
const result = algorithm.run(graph)

// highlight the trees
for (const tree of result.trees) {
  for (const node of tree.nodes) {
    graph.setStyle(node, highlightNodeStyle)
  }
  for (const edge of tree.edges) {
    graph.setStyle(edge, highlightEdgeStyle)
  }
}
Finding only the trees in a graph whose nodes are of the same type
// prepare the tree detection algorithm
const algorithm = new TreeSubstructures({
  // only nodes with the same tags can be a tree
  nodeTypes: (node) => node.tag
})
// run the algorithm
const result = algorithm.run(graph)

// highlight the trees
for (const tree of result.trees) {
  for (const node of tree.nodes) {
    graph.setStyle(node, highlightNodeStyle)
  }
  for (const edge of tree.edges) {
    graph.setStyle(edge, highlightEdgeStyle)
  }
}// prepare the tree detection algorithm
const algorithm = new TreeSubstructures({
  // only nodes with the same tags can be a tree
  nodeTypes: (node: INode): any => node.tag
})
// run the algorithm
const result = algorithm.run(graph)

// highlight the trees
for (const tree of result.trees) {
  for (const node of tree.nodes) {
    graph.setStyle(node, highlightNodeStyle)
  }
  for (const edge of tree.edges) {
    graph.setStyle(edge, highlightEdgeStyle)
  }
}

Type Details

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

See Also

The smallest minimumSize value that could be considered is 3.
A chain or star structure is also considered to be a tree.
If no edgeDirectedness is specified, all edges are treated as undirected. Furthermore, if no nodeTypes are specified, all node are considered to be of the same type.

Constructors

Properties

Methods