Learn R Programming

caugi (version 1.0.0)

read_graphml: 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)

Value

A caugi object.

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.

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

Run this code
# 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)

Run the code above in your browser using DataLab