xgi.readwrite.json

Read from and write to JSON.

Functions

xgi.readwrite.json.read_json(path, nodetype=None, edgetype=None)[source]

A function to read a file in a standardized JSON format.

Parameters:
  • data (dict) – A dictionary in the hypergraph JSON format

  • nodetype (type, optional) – type that the node IDs will be cast to

  • edgetype (type, optional) – type that the edge IDs will be cast to

Returns:

The loaded hypergraph

Return type:

A Hypergraph object

Raises:

XGIError – If the JSON is not in a format that can be loaded.

xgi.readwrite.json.write_json(H, path)[source]

A function to write a file in a standardized JSON format.

Parameters:
  • H (Hypergraph object) – The specified hypergraph object

  • path (string) – The path of the file to read from