Skip to contents

Convenience helpers that build small undirected graph families as two-column integer edge matrices suitable for grip(). These helpers are meant for examples, experiments, and reproducible tests.

Usage

edges.path(n)

edges.cycle(n)

edges.mesh(h, w = h, connectivity = c("orthogonal", "diagonal"))

edges.occupied.mesh(keep, connectivity = c("orthogonal", "diagonal"))

edges.cylinder(h, w = h)

edges.torus(h, w = h)

edges.irregular.ball(
  base = c("tetrahedron", "octahedron", "icosahedron"),
  level = 1,
  layers = 3,
  outer_radius = 1,
  radial_irregularity = 0.25,
  layer_twist = 0.35
)

edges.irregular.shell(
  base = c("tetrahedron", "octahedron", "icosahedron"),
  level = 1,
  layers = 3,
  inner_radius = 0.45,
  outer_radius = 1,
  radial_irregularity = 0.25,
  layer_twist = 0.35
)

edges.irregular.torus(
  major_rings = 8,
  tube_count = 16,
  count_irregularity = 0.2,
  major_irregularity = 0.25,
  phase_twist = 0.35
)

edges.sphere(h, w = h)

edges.irregular.annulus(
  rings = 6,
  outer_count = 28,
  outer_radius = 1,
  inner_radius = 0.45,
  count_irregularity = 0.2,
  radial_irregularity = 0.35,
  phase_twist = 0.35
)

edges.irregular.pair.of.pants(
  slices = 11,
  outer_count = 28,
  outer_radius = 1.1,
  hole_radius = 0.24,
  hole_offset = 0.38,
  hole_height = 0.18,
  count_irregularity = 0.2,
  vertical_irregularity = 0.35,
  phase_twist = 0.35
)

edges.irregular.double.torus(
  slices = 11,
  tube_count = 14,
  branch_length = 0.85,
  branch_offset = 0.72,
  tube_radius = 0.28,
  transition_width = 0.42,
  count_irregularity = 0.2,
  axial_irregularity = 0.3,
  phase_twist = 0.35
)

edges.irregular.sphere(
  bands = 6,
  equator_count = 28,
  count_irregularity = 0.2,
  lat_irregularity = 0.35,
  phase_twist = 0.35
)

edges.cube(side = 2)

edges.kary.tree(k = 2, depth = 2)

edges.recursive.mask.grid(mask, level = 2)

edges.recursive.triangle.mask(mask = mask.triangle.classic(), level = 2)

edges.recursive.tetrahedron.mask(mask = mask.tetrahedron.classic(), level = 2)

edges.recursive.cube.mask(mask, level = 2)

edges.triangulated.polyhedron(
  base = c("tetrahedron", "octahedron", "icosahedron"),
  level = 1
)

edges.triangulated.annulus(
  resolution = 12,
  outer_radius = 1,
  inner_radius = 0.45
)

edges.triangulated.pair.of.pants(
  resolution = 12,
  outer_radius = 1.1,
  hole_radius = 0.24,
  hole_offset = 0.38,
  hole_height = 0.18
)

edges.vicsek(level = 2)

edges.menger.sponge(level = 2)

edges.cube.periodic.tunnels(
  level = 2,
  side = 5,
  tunnel_width = 1,
  tunnel_period = 2,
  tunnel_offset = 2
)

edges.cube.asymmetric.cavities(
  level = 2,
  side = 5,
  cavity_size = 2,
  pocket_size = max(1L, cavity_size - 1L)
)

edges.cube.channel.network(
  level = 2,
  side = 5,
  channel_width = 1,
  branch_offset = 2
)

edges.sierpinski.triangle(level = 2)

edges.sierpinski.tetrahedron(level = 2)

edges.sierpinski.carpet(level = 2)

Arguments

n

Number of vertices.

h

Number of rows.

w

Number of columns. Defaults to h.

connectivity

Mesh neighborhood rule. "orthogonal" keeps the 4-neighbor grid; "diagonal" also adds both diagonals of every unit square.

keep

Logical or numeric occupancy matrix. Non-zero entries are kept.

base

Base polyhedron for edges.triangulated.polyhedron(). One of "tetrahedron", "octahedron", or "icosahedron".

level

Recursion depth. For edges.recursive.mask.grid(), edges.recursive.cube.mask(), edges.vicsek(), edges.menger.sponge(), and edges.sierpinski.carpet(), level must be at least 1; edges.recursive.triangle.mask(), edges.recursive.tetrahedron.mask(), and edges.triangulated.polyhedron() also allow level = 0.

layers

Number of non-center radial layers for edges.irregular.ball() and number of inner-to-outer layers for edges.irregular.shell().

outer_radius

Positive outer boundary radius for edges.triangulated.annulus() and edges.triangulated.pair.of.pants().

radial_irregularity

Within-ring radial irregularity level for edges.irregular.annulus().

layer_twist

Finite z-axis twist applied across radial layers in edges.irregular.ball() and edges.irregular.shell().

inner_radius

Positive inner annulus radius for edges.triangulated.annulus().

major_rings

Number of cyclic major rings for edges.irregular.torus().

tube_count

Approximate number of vertices around each minor cycle for edges.irregular.torus() and around each tube-like loop for edges.irregular.double.torus().

count_irregularity

Irregularity level for sample counts in edges.irregular.torus(), edges.irregular.annulus(), edges.irregular.pair.of.pants(), edges.irregular.double.torus(), and edges.irregular.sphere().

major_irregularity

Major-angle ring-spacing irregularity level for edges.irregular.torus().

phase_twist

Angular phase offset used to desynchronize neighboring rings, slice samples, or latitude bands in the irregular torus, irregular annulus, irregular pair-of-pants, irregular double torus, and irregular sphere families.

rings

Number of concentric sample rings for edges.irregular.annulus().

outer_count

Approximate number of vertices on the outer boundary for edges.irregular.annulus() and across the widest slices for edges.irregular.pair.of.pants().

slices

Number of horizontal sample slices for edges.irregular.pair.of.pants().

hole_radius

Positive radius of each interior hole for edges.triangulated.pair.of.pants().

hole_offset

Positive horizontal offset of the two hole centers for edges.triangulated.pair.of.pants().

hole_height

Shared vertical coordinate of the two hole centers for edges.triangulated.pair.of.pants().

vertical_irregularity

Slice-spacing irregularity level for edges.irregular.pair.of.pants().

branch_length

Half-length of the three-loop central region for edges.irregular.double.torus().

branch_offset

Offset of the outer loop centers from the middle loop for edges.irregular.double.torus().

tube_radius

Baseline radius of each tube-like loop for edges.irregular.double.torus().

transition_width

Width of the single-loop to three-loop transition regions for edges.irregular.double.torus().

axial_irregularity

Slice-spacing irregularity level for edges.irregular.double.torus().

bands

Number of non-pole latitude bands for edges.irregular.sphere().

equator_count

Approximate number of vertices near the equator for edges.irregular.sphere().

lat_irregularity

Latitude-band spacing irregularity level for edges.irregular.sphere().

side

Number of lattice points along each cube edge.

k

Branching factor.

depth

Number of levels below the root.

mask

Keep-mask describing which recursive cells are retained. For edges.recursive.mask.grid(), mask must be a square logical or numeric keep-matrix whose non-zero entries are kept at each recursive subdivision step. For edges.recursive.triangle.mask(), mask must instead be a four-entry vector in left, right, top, center order, and for edges.recursive.tetrahedron.mask(), mask must be a four-entry vector in base_left, base_right, base_back, apex order. For edges.recursive.cube.mask(), mask must be a cubic logical or numeric keep-array whose non-zero entries are kept at each recursive subdivision step.

resolution

Positive lattice-resolution control used by edges.triangulated.annulus() and edges.triangulated.pair.of.pants().

tunnel_width

Width of each removed tunnel band in edges.cube.periodic.tunnels().

tunnel_period

Spacing between successive tunnel bands in edges.cube.periodic.tunnels().

tunnel_offset

Starting index of the first tunnel band in edges.cube.periodic.tunnels().

cavity_size

Side length of the larger interior cavity block in edges.cube.asymmetric.cavities().

pocket_size

Side length of the smaller secondary cavity block in edges.cube.asymmetric.cavities().

channel_width

Width of each removed channel in edges.cube.channel.network().

Value

A two-column integer matrix of undirected edges. Vertex labels are consecutive integers starting at 1.

Details

The occupied-grid, recursive masked-grid, and Sierpinski families are exposed explicitly rather than overloading a single generator with layout-dimension-dependent behavior: edges.occupied.mesh() builds a finite perforated-mesh family from an occupancy matrix, edges.recursive.mask.grid() builds a generic square-mask family, edges.recursive.triangle.mask() builds a generic triangle-mask family, edges.recursive.tetrahedron.mask() builds a generic tetrahedron-mask family, edges.recursive.cube.mask() builds a generic cube-mask family, edges.vicsek() builds the connected axial-cross variant, edges.menger.sponge() builds the classic cubical sponge variant, edges.triangulated.polyhedron() builds a generic irregular triangulated-surface family, edges.sierpinski.triangle() builds the 2-simplex family, edges.sierpinski.tetrahedron() builds the 3-simplex family, and edges.sierpinski.carpet() builds a 2D cell-adjacency carpet graph.

Functions

  • edges.path(): Path graph on n vertices.

  • edges.cycle(): Cycle graph on n vertices.

  • edges.mesh(): Rectangular grid graph with h rows and w columns.

  • edges.occupied.mesh(): Rectangular occupied-grid graph whose vertices are kept cells and whose edges connect orthogonally adjacent kept cells. With connectivity = "diagonal", both diagonals are added for every fully occupied 2-by-2 block.

  • edges.cylinder(): Cylindrical grid graph with h rows and wrapped width w.

  • edges.torus(): Toroidal grid graph with wrapped height and width.

  • edges.irregular.ball(): Deterministically irregular tetrahedralized ball graph built from nested subdivided polyhedral shells connected by a layered prism-to-tetrahedra edge pattern.

  • edges.irregular.shell(): Deterministically irregular tetrahedralized shell graph built from nested subdivided polyhedral shells connected by a layered prism-to-tetrahedra edge pattern.

  • edges.irregular.torus(): Deterministically irregular torus graph built from major-cycle rings with varying sample counts and stitched into a locally triangulated closed surface.

  • edges.sphere(): Sphere surface graph with h latitude levels (including the poles) and wrapped longitude w.

  • edges.irregular.annulus(): Deterministically irregular annulus graph built from concentric sample rings with varying sample counts and stitched into a locally triangulated surface-with-boundary graph.

  • edges.irregular.pair.of.pants(): Deterministically irregular pair-of-pants graph built from horizontal slice intervals with varying sample counts and stitched into a locally triangulated surface-with-boundary graph.

  • edges.irregular.double.torus(): Deterministically irregular double-torus graph built from cyclic slices whose cross-sections follow a `1 -> 3 -> 1` loop transition between two poles.

  • edges.irregular.sphere(): Deterministically irregular sphere graph built from latitude bands with varying sample counts and stitched into a locally triangulated closed surface.

  • edges.cube(): Cube surface graph on the boundary of a side x side x side lattice.

  • edges.kary.tree(): Full k-ary tree of depth depth.

  • edges.recursive.mask.grid(): Recursively refined square-mask grid graph whose vertices are occupied cells and whose edges connect orthogonally adjacent cells.

  • edges.recursive.triangle.mask(): Recursively refined triangle-mask graph whose vertices are the retained subdivision vertices of an equilateral triangle.

  • edges.recursive.tetrahedron.mask(): Recursively refined tetrahedron-mask graph whose vertices are the retained subdivision vertices of a tetrahedron.

  • edges.recursive.cube.mask(): Recursively refined cube-mask graph whose vertices are occupied subcubes and whose edges connect face-adjacent occupied cells.

  • edges.triangulated.polyhedron(): Triangulated closed-surface graph obtained by repeatedly splitting the triangular faces of a tetrahedron, octahedron, or icosahedron.

  • edges.triangulated.annulus(): Triangulated annulus graph obtained by clipping a regular triangular lattice to the region between two concentric circles.

  • edges.triangulated.pair.of.pants(): Triangulated pair-of-pants graph obtained by clipping a regular triangular lattice to a disk with two interior circular holes.

  • edges.vicsek(): Connected Vicsek-style cross family derived from a 3 x 3 axial-cross keep-mask.

  • edges.menger.sponge(): Classic Menger-sponge cubical cell-adjacency graph derived from the 3 x 3 x 3 keep-mask that removes the center cube and the six face-center cubes at each recursion step.

  • edges.cube.periodic.tunnels(): Periodic cubical tunnel family derived from a repeated tunnel-band keep-mask. The classic Menger sponge appears as the side = 3, tunnel_width = 1 special case.

  • edges.cube.asymmetric.cavities(): Cubical porous family with two offset interior cavity blocks repeated recursively.

  • edges.cube.channel.network(): Cubical porous family with a deterministic branched channel network carved through each recursive block.

  • edges.sierpinski.triangle(): Two-dimensional Sierpinski triangle graph at recursion depth level.

  • edges.sierpinski.tetrahedron(): Three-dimensional tetrahedral Sierpinski graph at recursion depth level.

  • edges.sierpinski.carpet(): Two-dimensional Sierpinski carpet graph whose vertices are occupied cells and whose edges connect orthogonally adjacent cells.

Examples

edges <- edges.path(6)
coords <- grip(edges, n = 6, dim = 2, seed = 1)
plot.layout(coords, edges, main = "Path graph", pch = 16, cex = 0.8)

edges <- edges.sierpinski.triangle(2)
n <- max(edges)
coords <- grip(edges, n = n, dim = 2,
                      placement = "circle",
                      seed = 1)
plot.layout(coords, edges, main = "Sierpinski triangle", pch = 16, cex = 0.7)