Skip to contents

Converts a graph-like object into a named probability mass function (PMF) describing one selected graph summary. This provides a standardized bridge between graph objects and divergence functions such as jensen.shannon.divergence().

Supported v1 summaries are:

  • "degree_distribution"

  • "edge_weight_distribution"

  • "component_size_distribution"

  • "neighborhood_label_distribution"

"component_size_distribution" is included primarily as a diagnostic for disconnectedness / fragmentation, not as a general-purpose default stability summary.

Usage

compute.graph.summary.pmf(
  graph,
  summary = c("degree_distribution", "edge_weight_distribution",
    "component_size_distribution", "neighborhood_label_distribution"),
  labels = NULL,
  edge.attribute = "length",
  stage = "final",
  bins = NULL,
  n.bins = 20L,
  bin.method = c("auto", "fixed_width", "fixed_quantile", "explicit"),
  normalize = TRUE,
  support = NULL,
  zero.pad = TRUE,
  return.details = TRUE
)

Arguments

graph

A dgraph object.

summary

Summary type to compute.

labels

Optional label vector used for "neighborhood_label_distribution". Must have length equal to the number of vertices.

edge.attribute

Edge quantity for the edge-value distribution; default "length".

stage

Stored graph stage to summarize.

bins

Optional numeric vector of histogram breaks used for "edge_weight_distribution".

n.bins

Integer number of bins used when bins is NULL and the summary is "edge_weight_distribution".

bin.method

Character string controlling automatic bin construction for "edge_weight_distribution".

normalize

Logical; if TRUE, convert counts to a PMF.

support

Optional support to align the resulting PMF to.

zero.pad

Logical; if TRUE and support is provided, missing support entries are padded with zero mass.

return.details

Logical; if TRUE, return a structured list. Otherwise return the named PMF directly.

Value

If return.details = TRUE, a list with fields:

  • summary: summary type used.

  • pmf: named probability mass function.

  • support: support of the PMF.

  • counts: named raw-count vector before normalization.

  • metadata: list of summary-specific metadata.

Otherwise, returns the named PMF vector.

Examples

graph <- dgraph(list(c(2L, 3L), 1L, 1L))
compute.graph.summary.pmf(graph, summary = "degree_distribution")
#> $summary
#> [1] "degree_distribution"
#> 
#> $pmf
#>         1         2 
#> 0.6666667 0.3333333 
#> 
#> $support
#> [1] "1" "2"
#> 
#> $counts
#> 1 2 
#> 2 1 
#> 
#> $metadata
#> $metadata$n.vertices
#> [1] 3
#> 
#> $metadata$n.edges
#> [1] 2
#> 
#> $metadata$directed
#> [1] FALSE
#> 
#> $metadata$simplify.multiple
#> [1] TRUE
#> 
#>