permute_graph_splits: Permute all ways to split a graph

View source: R/permute_graph_splits.r

permute_graph_splitsR Documentation

Permute all ways to split a graph

Description

Given a graph represented by an adjacency matrix, permutes all ways this graph could be split apart.

Usage

permute_graph_splits(adjacency_matrix)

Arguments

adjacency_matrix

A labelled adjacency matrix where the diagonal is zeroes and the off-diagonal either ones (if the two vertices are directly connected) or zeroes (if not directly connected). Labels must match across row names and column names,

Details

This function takes a connected graph and considers all the ways it could be split by removing every possible combination of edges (inclusive of none and all).

Value

A vector of splits where connected vert(ices) are listed with "+" joining them and disconnected vert(ices) are separated by "|".

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

Examples


# Create a connected graph matrix:
adjacency_matrix <- matrix(
  data = c(
    0, 1, 0, 0, 1, 0,
    1, 0, 1, 0, 1, 0,
    0, 1, 0, 1, 0, 0,
    0, 0, 1, 0, 1, 1,
    1, 1, 0, 1, 0, 0,
    0, 0, 0, 1, 0, 0
  ),
  ncol = 6,
  byrow = TRUE,
  dimnames = list(
    LETTERS[1:6],
    LETTERS[1:6]
  )
)

# Check graph is connectedPermute all ways to split graph (remove edges):
permute_graph_splits(adjacency_matrix = adjacency_matrix)


Claddis documentation built on Sept. 11, 2024, 9:18 p.m.