Learn R Programming

cograph (version 2.0.0)

network_girth: Network Girth (Shortest Cycle Length)

Description

Computes the girth of a network - the length of the shortest cycle. Returns Inf for acyclic graphs (trees, DAGs).

Usage

network_girth(x, ...)

Value

Integer: length of shortest cycle, or Inf if no cycles exist

Arguments

x

Network input: matrix, igraph, network, cograph_network, or tna object

...

Additional arguments passed to to_igraph

Examples

Run this code
# Triangle has girth 3
triangle <- matrix(c(0,1,1, 1,0,1, 1,1,0), 3, 3)
network_girth(triangle)  # 3

# Tree has no cycles (Inf)
tree <- matrix(c(0,1,0, 1,0,1, 0,1,0), 3, 3)
network_girth(tree)  # Inf

Run the code above in your browser using DataLab