 PGX 20.1.1
Documentation

# Degree Centrality Algorithms

PGX 20.1.1 has three different algorithms for degree centrality. One for centrality based on out-degree, one for centrality based on in-degree and one for centrality based on the sum of those two.

## In-Degree Centrality

##### Categoryranking and walkingAlgorithm IDpgx_builtin_k7b_indegree_centralityTime ComplexityO(V) with V = number of verticesSpace RequirementO(V) with V = number of verticesJavadocAnalyst#inDegreeCentrality(PgxGraph graph) Analyst#inDegreeCentrality(PgxGraph graph, VertexProperty dc)

In-Degree centrality returns the sum of the number of incoming edges for each vertex in the graph.

### Signature

Input Argument Type Comment
G graph
Output Argument Type Comment
ic nodeProp vertex property holding the degree centrality value for each vertex in the graph.

### Code

```/*
*/
package oracle.pgx.algorithms;

import oracle.pgx.algorithm.annotations.GraphAlgorithm;
import oracle.pgx.algorithm.PgxGraph;
import oracle.pgx.algorithm.VertexProperty;
import oracle.pgx.algorithm.annotations.Out;

@GraphAlgorithm
public class IndegreeCentrality {
public void indegreeCentrality(PgxGraph g, @Out VertexProperty<Integer> indegreeCentrality) {
g.getVertices().forEach(n ->
indegreeCentrality.set(n, (int) n.getInDegree())
);
}
}
```
```/*
*/

proc indegree_centrality(graph G; nodeProp<int> ic) {

foreach (n: G.nodes) {
n.ic = n.inDegree();
}
}
```

## Out-Degree Centrality

##### Categoryranking and walkingAlgorithm IDpgx_builtin_k7a_outdegree_centralityTime ComplexityO(V) with V = number of verticesSpace RequirementO(V) with V = number of verticesJavadocAnalyst#outDegreeCentrality(PgxGraph graph) Analyst#outDegreeCentrality(PgxGraph graph, VertexProperty dc)

Out-Degree centrality returns the sum of the number of outgoing edges for each vertex in the graph.

### Signature

Input Argument Type Comment
G graph
Output Argument Type Comment
oc nodeProp vertex property holding the degree centrality value for each vertex in the graph.

### Code

```/*
*/
package oracle.pgx.algorithms;

import oracle.pgx.algorithm.annotations.GraphAlgorithm;
import oracle.pgx.algorithm.PgxGraph;
import oracle.pgx.algorithm.VertexProperty;
import oracle.pgx.algorithm.annotations.Out;

@GraphAlgorithm
public class OutdegreeCentrality {
public void outdegreeCentrality(PgxGraph g, @Out VertexProperty<Integer> outdegreeCentrality) {
g.getVertices().forEach(n ->
outdegreeCentrality.set(n, (int) n.getOutDegree())
);
}
}
```
```/*
*/

proc outdegree_centrality(graph G; nodeProp<int> oc) {

foreach (n: G.nodes) {
n.oc = n.degree();
}
}
```

## Degree Centrality

##### Categoryranking and walkingAlgorithm IDpgx_builtin_k7c_degree_centralityTime ComplexityO(V) with V = number of verticesSpace RequirementO(V) with V = number of verticesJavadocAnalyst#degreeCentrality(PgxGraph graph) Analyst#degreeCentrality-oracle.pgx.api.PgxGraph-oracle.pgx.api.VertexProperty-

Degree centrality counts the number of outgoing and incoming edges for each vertex in the graph.

### Signature

Input Argument Type Comment
G graph
Output Argument Type Comment
dc nodeProp vertex property holding the degree centrality value for each vertex in the graph.

### Code

```/*
*/
package oracle.pgx.algorithms;

import oracle.pgx.algorithm.annotations.GraphAlgorithm;
import oracle.pgx.algorithm.PgxGraph;
import oracle.pgx.algorithm.VertexProperty;
import oracle.pgx.algorithm.annotations.Out;

@GraphAlgorithm
public class DegreeCentrality {
public void degreeCentrality(PgxGraph g, @Out VertexProperty<Integer> degreeCentrality) {
g.getVertices().forEach(n ->
degreeCentrality.set(n, (int) (n.getOutDegree() + n.getInDegree()))
);
}
}
```
```/*