documentationfor yFiles for HTML 2.6

Computes the layers of nodes constructed by a directed or undirected breadth-first search.

Inheritance Hierarchy
Bfs

Remarks

The first of these layers contains all coreNodes from which a breadth-first search to the other nodes starts.

Each layer i contains nodes that have a path of length i to at least one of the coreNodes. Nodes that are unreachable because there is no path to them, or the path's length exceeds layerCount have a layer index of -1 instead.

The search can be directed or undirected. In a directed search the edges can be traversed either forwards (from source to target) or backwards.

Examples

// configure the algorithm
const algorithm = new Bfs({
  // specify the nodes of the 0-th layer to start from
  coreNodes: centerNode
})
// run the algorithm
const result = algorithm.run(graph)
// add labels to indicate the layer
result.nodeLayerIds.forEach(({ key: node, value: id }) =>
  graph.addLabel(node, String(id))
)

Type Details

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

See Also

Constructors

Properties

Methods