documentationfor yFiles for HTML 2.6

WeightCentrality

Computes the weight centrality for the nodes of a graph.

Inheritance Hierarchy
WeightCentrality

Remarks

Weight centrality measures the weight associated with incoming, outgoing, or all edges of a node.

When no weights are associated with edges, weight centrality becomes the same as DegreeCentrality.

Other Centrality Measures

yFiles for HTML supports a number of other centrality measures:

Examples

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

// 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 WeightCentrality({
  considerIncomingEdges: false,
  considerOutgoingEdges: true,
  // Use the geometric edge length as weight
  weights: (edge) =>
    edge.style.renderer
      .getPathGeometry(edge, edge.style)
      .getPath()!
      .getLength()
}).run(graph)

// 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.WeightCentrality

See Also

Constructors

Properties

Methods