Learn R Programming

caugi (version 1.0.0)

to_graphml: Export caugi Graph to GraphML Format

Description

Converts a caugi graph to the GraphML XML format as a string. GraphML is widely supported by graph analysis tools and libraries.

Usage

to_graphml(x)

Value

A caugi_graphml object containing the GraphML representation.

Arguments

x

A caugi object.

Details

The GraphML export includes:

  • Node IDs and labels

  • Edge types stored as a custom edge_type attribute

  • Graph class stored as a graph-level attribute

Edge types are encoded using the caugi DSL operators (e.g., "-->", "<->"). This allows for perfect round-trip conversion back to caugi.

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(), read_graphml(), to_dot(), to_mermaid(), write_caugi(), write_dot(), write_graphml(), write_mermaid()

Examples

Run this code
cg <- caugi(
  A %-->% B + C,
  B %-->% D,
  C %-->% D,
  class = "DAG"
)

# Get GraphML string
graphml <- to_graphml(cg)
cat(graphml@content)

# Write to file
if (FALSE) {
write_graphml(cg, "graph.graphml")
}

Run the code above in your browser using DataLab