read_graphml: Read GraphML File to caugi Graph

View source: R/format-graphml.R

read_graphmlR Documentation

Read GraphML File to caugi Graph

Description

Imports a GraphML file as a caugi graph. Supports GraphML files exported from caugi with full edge type information.

Usage

read_graphml(path, class = NULL)

Arguments

path

File path to the GraphML file.

class

Graph class to assign. If NULL (default), attempts to read from the GraphML metadata. If not present, defaults to "UNKNOWN".

Details

This function provides basic GraphML import support. It reads:

  • Nodes and their IDs

  • Edges with source and target

  • Edge types (if present in edge_type attribute)

  • Graph class (if present in graph data)

For GraphML files not created by caugi, edge types default to "–>" for directed graphs and "—" for undirected graphs.

Value

A caugi object.

See Also

Other export: caugi_deserialize(), caugi_dot(), caugi_export(), caugi_graphml(), caugi_mermaid(), caugi_serialize(), export-classes, format-caugi, format-dot, format-graphml, format-mermaid, knit_print.caugi_export(), read_caugi(), to_dot(), to_graphml(), to_mermaid(), write_caugi(), write_dot(), write_graphml(), write_mermaid()

Examples

# Create and export a graph
cg <- caugi(
  A %-->% B,
  B %-->% C,
  class = "DAG"
)

tmp <- tempfile(fileext = ".graphml")
write_graphml(cg, tmp)

# Read it back
cg2 <- read_graphml(tmp)

# Clean up
unlink(tmp)


caugi documentation built on Oct. 28, 2026, 1:07 a.m.