PGX 20.2.2
Documentation

# Degree Distribution Algorithms

PGX 20.2.2 has two algorithms to compute the degree distribution. One for the out-degree and one for the in-degree distribution.

## Out-Degree Distribution

##### Categorystructure evaluationAlgorithm IDpgx_builtin_s6_out_degree_distributionTime ComplexityO(V) with V = number of verticesSpace RequirementO(V) with V = number of verticesJavadocAnalyst#outDegreeCentrality(PgxGraph graph) Analyst#outDegreeCentrality(PgxGraph graph, VertexProperty dc)

This version of the degree distribution will return a map with the distirbution of the out-degree (i.e. just outgoing edges) of the graph. For undirected graphs the algorithm will consider all the edges (incoming and outgoing) for the distribution.

### Signature

Input Argument Type Comment
G graph
Output Argument Type Comment
distribution map map holding a histogram of the node degrees in the graph.

### Code

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

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

@GraphAlgorithm
public class OutdegreeDistribution {
public void outdegreeDistribution(PgxGraph g, @Out PgxMap<Long, Long> distribution) {
g.getVertices().forSequential(n -> {
long degree = n.getOutDegree();

distribution.increment(degree);
});
}
}
```
```/*
*/

procedure outdegree_distribution(graph G; map<int, long> distribution) {

for (n: G.nodes) {
int degree = n.outDegree();
distribution[degree]++;
}
}
```

## In-Degree Distribution

##### Categorystructure evaluationAlgorithm IDpgx_builtin_s7_in_degree_distributionTime ComplexityO(V) with V = number of verticesSpace RequirementO(V) with V = number of verticesJavadocAnalyst#inDegreeDistribution(PgxGraph graph) Analyst#inDegreeDistribution(PgxGraph graph, PgxMap distribution)

This version of the degree distribution will return a map with the distribution of the in-degree (i.e. just incoming edges) of the graph. For undirected graphs the algorithm will consider all the edges (incoming and outgoing) for the distribution.

### Signature

Input Argument Type Comment
G graph
Output Argument Type Comment
distribution map map holding a histogram of the vertex degrees in the graph.

### Code

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

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

@GraphAlgorithm
public class IndegreeDistribution {
public void indegreeDistribution(PgxGraph g, @Out PgxMap<Long, Long> distribution) {
g.getVertices().forSequential(n -> {
long degree = n.getInDegree();

distribution.increment(degree);
});
}
}
```
```/*