Skip to contents

A small, separate export helper – deliberately NOT part of the precise_viz router (the router returns panel objects and performs no file I/O). Accepts a single matrix, or one similarity-typed row of a typed tibble selected by key. Distance-typed rows are refused because exporting distances as edge weights makes large dissimilarities look like strong graph edges.

Usage

precise_graphml(data, file, key = NULL)

Arguments

data

A square, symmetric numeric matrix (e.g. graph_out$matrix[[i]]), or a typed tibble from which key= selects one row.

file

Path to the .graphml file to write (must not already exist).

key

When data is a typed tibble: the distance/method key of the row to export.

Value

Invisibly, the normalized path written.

Examples

adjacency <- matrix(
  c(0, 1, 0.2, 1, 0, 0.5, 0.2, 0.5, 0),
  nrow = 3,
  byrow = TRUE
)
dimnames(adjacency) <- list(letters[1:3], letters[1:3])
graphml_file <- tempfile(fileext = ".graphml")
precise_graphml(adjacency, graphml_file)
file.exists(graphml_file)
#> [1] TRUE