Skip to content

Latest commit

 

History

History
50 lines (39 loc) · 1.84 KB

pgx_builtin_s6_out_degree_distribution.md

File metadata and controls

50 lines (39 loc) · 1.84 KB

Out-Degree Distribution

This version of the degree distribution will return a map with the distribution 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 the graph.
Output Argument Type Comment
distribution map<int, long> map holding a histogram of the node degrees in the graph.
Return Value Type Comment
void None

Code

/*
 * Copyright (C) 2013 - 2025 Oracle and/or its affiliates. All rights reserved.
 */
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);
    });
  }
}