documentationfor yFiles for HTML 2.6

BetweennessCentrality

Computes the betweenness centrality for each node and edge of a given graph.

Inheritance Hierarchy
BetweennessCentrality

Remarks

Betweenness centrality is a measure for how often a node/edge lies on a shortest path between each pair of nodes in the graph. Removing a central node/edge will cause many shortest paths to change.

The centrality can be computed for directed and undirected graphs.

weights can be assigned to each edge. If no weights are provided, then all edges have uniform weight.

Other Centrality Measures

yFiles for HTML supports a number of other centrality measures:

Examples

const result = new BetweennessCentrality({
  directed: true,
  // Use the geometric edge length as weight
  weights: (edge) =>
    edge.style.renderer
      .getPathGeometry(edge, edge.style)
      .getPath()
      .getLength()
}).run(graph)

// add edge labels for centrality values
result.normalizedEdgeCentrality.forEach(({ key, value }) => {
  const edge = key
  const centrality = value
  graph.addLabel(edge, String(centrality))
})

// add node labels for centrality values
// and adjust node size according to centrality
result.normalizedNodeCentrality.forEach(({ key, value }) => {
  const node = key
  const centrality = value
  graph.addLabel(key, String(value))
  graph.setNodeLayout(
    node,
    new Rect(node.layout.center, new Size(centrality, centrality))
  )
})const result = new BetweennessCentrality({
  directed: true,
  // Use the geometric edge length as weight
  weights: (edge) =>
    edge.style.renderer
      .getPathGeometry(edge, edge.style)
      .getPath()!
      .getLength()
}).run(graph)

// add edge labels for centrality values
result.normalizedEdgeCentrality.forEach(({ key, value }) => {
  const edge = key
  const centrality = value
  graph.addLabel(edge, String(centrality))
})

// add node labels for centrality values
// and adjust node size according to centrality
result.normalizedNodeCentrality.forEach(({ key, value }) => {
  const node = key
  const centrality = value
  graph.addLabel(key, String(value))
  graph.setNodeLayout(
    node,
    new Rect(node.layout.center, new Size(centrality, centrality))
  )
})

Type Details

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

See Also

Constructors

Properties

Methods