documentationfor yFiles for HTML 2.6

CycleSubstructures

Detects SubstructureItemss that represent the isolated cycles in the specified graph.

Inheritance Hierarchy
CycleSubstructures

Remarks

A cycle is a simple edge path in which the first and last nodes are identical. The algorithm only considers cycles in which at most one edge connects a cycle node with the rest of the graph (i.e. isolated cycles that are connected with one edge). Furthermore, a cycle only consists of elements with the same edgeDirectedness and 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 cycles in a graph
// prepare the cycle detection algorithm
const algorithm = new CycleSubstructures()
// run the algorithm
const result = algorithm.run(graph)

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

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

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

Type Details

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

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