Skip to contents

Converts a caugi graph to a JSON string in the native caugi format. This is a lower-level function; consider using write_caugi() for writing to files.

Usage

caugi_serialize(x, comment = NULL, tags = NULL)

Arguments

x

A caugi object or an object coercible to caugi.

comment

Optional character string with a comment about the graph.

tags

Optional character vector of tags for categorizing the graph.

Value

A character string containing the JSON representation.

Examples

cg <- caugi(A %-->% B, class = "DAG")
json <- caugi_serialize(cg)
cat(json)
#> {
#>   "$schema": "https://caugi.org/schemas/caugi-v1.schema.json",
#>   "format": "caugi",
#>   "version": "1.0.0",
#>   "graph": {
#>     "class": "DAG",
#>     "nodes": [
#>       "A",
#>       "B"
#>     ],
#>     "edges": [
#>       {
#>         "from": "A",
#>         "to": "B",
#>         "edge": "-->"
#>       }
#>     ]
#>   }
#> }