Skip to contents

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".

Value

A caugi object.

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.

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)