Skip to contents

Computes node coordinates for bipartite graphs, placing nodes in two parallel lines (rows or columns) based on a partition. If the graph has not been built yet, it will be built automatically before computing the layout.

Usage

caugi_layout_bipartite(x, partition = NULL, orientation = c("columns", "rows"))

Arguments

x

A caugi object.

partition

Optional logical vector indicating node partitions. Nodes with TRUE are placed in one partition and nodes with FALSE in the other. Length must equal the number of nodes. Both partitions must be non-empty. If NULL (default), attempts to detect bipartite structure automatically by assigning nodes without incoming edges to one partition and others to the second partition.

orientation

Character string specifying the layout orientation:

  • "columns": Two vertical columns. First partition on right (x=1), second partition on left (x=0).

  • "rows": Two horizontal rows. First partition on top (y=1), second partition on bottom (y=0).

Value

A data.frame with columns name, x, and y containing node names and their coordinates.

Examples

# Create a bipartite graph (causes -> effects)
cg <- caugi(A %-->% X, A %-->% Y, B %-->% X, B %-->% Y)
partition <- c(TRUE, TRUE, FALSE, FALSE) # A, B = causes, X, Y = effects

# Two horizontal rows (causes on top)
layout_rows <- caugi_layout_bipartite(cg, partition, orientation = "rows")

# Two vertical columns (causes on right)
layout_cols <- caugi_layout_bipartite(cg, partition, orientation = "columns")