---
title: "Weighted Degree Centrality"
description: "Overview of the weighted degree centrality algorithm."
component: "graph-ml"
version: "3.10"
module: "centrality-algorithms"
html_url: "/graph-ml/3.10/centrality-algorithms/weighted-degree-centrality"
canonical_url: "https://www.tigergraph.com/docs/graph-ml/3.10/centrality-algorithms/weighted-degree-centrality"
markdown_url: "https://www.tigergraph.com/docs/graph-ml/3.10/centrality-algorithms/weighted-degree-centrality.md"
---

[View as HTML](https://www.tigergraph.com/docs/graph-ml/3.10/centrality-algorithms/weighted-degree-centrality)

# Weighted Degree Centrality

Supported Graph Characteristics

| Weighted edges |
| --- |
| Directed edges |
| Undirected edges |
| Homogeneous vertex types |

Algorithm: [Weighted Degree Centrality](https://github.com/tigergraph/gsql-graph-algorithms/blob/master/algorithms/Centrality/degree/weighted/tg%5Fweighted%5Fdegree%5Fcent.gsql)

Degree centrality is defined as the number of edges connected to a vertex. The degree can be interpreted in terms of the immediate risk of a vertex for catching whatever is flowing through the network.

Weighted degree centrality allows you to assign weights to the edges connected to a vertex.

## Specifications

```gsql
CREATE QUERY tg_weighted_degree_cent(STRING v_type, STRING e_type,
    STRING reverse_e_type, STRING weight_attribute, BOOL in_degree = TRUE,
    BOOL out_degree = TRUE, INT top_k=100, BOOL print_results = TRUE,
    STRING result_attribute = "",STRING file_path = "")
```

### Parameters

| Parameter | Description |
| --- | --- |
| `STRING v_type` | Vertex type to traverse. |
| `STRING e_type` | Edge type to traverse. |
| `STRING reverse_e_type` | Reverse vertex type to traverse and calculate in-degree. |
| `STRING weight_attribute` | The name of the attribute that indicates the weight of the edge. The attribute itself must be of type `INT`. |
| `BOOL in_degree` | Whether to count incoming edges when calculating degree centrality. |
| `BOOL out_degree` | Whether to count outgoing edges when calculating degree centrality. |
| `INT top_k` | The number of vertices with the highest degree centrality to return. |
| `BOOL print_results` | If true, return JSON results to standard output. |
| `STRING result_attribute` | If not empty, save the degree centrality of each vertex to this attribute. |
| `STRING file_path` | If not empty, output CSV results to this filepath. |

### Output

The vertices with the highest degree centrality scores along with their scores.

### Time complexity

The algorithm has a time complexity of \\(O(E)\\), where \\(E\\) is the total number of edges in the graph.

### Run commands

#### Schema-Free Query

```gsql
RUN QUERY tg_weighted_degree_cent (<parameters>)
```

#### Packaged Template Query

```gsql
CALL GDBMS_ALGO.centrality.weighted_degree_cent (<parameters>)
```

## See also

[Degree Centrality](https://www.tigergraph.com/docs/graph-ml/3.10/centrality-algorithms/degree-centrality.md)
