documentationfor yFiles for HTML 3.0.0.3

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

@PRODUCT@ 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)),
  )
})

Type Details

yFiles module
view-layout-bridge

See Also

Constructors

Properties

Methods