Skip to content

colltoaction/nx_yaml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nx_yaml

nx_yaml is a general purpose Hypergraph Intermediate Representation for YAML using NetworkX. It provides native semantics for higher-order applications such as Hypergraph Analysis, Quantum Computing, Geometric Deep Learning and Monoidal Computing.

There are two notebook tutorials: a basic one and an advanced one using XGI for higher-order interpretation.

Design

Graph Theory is well established in compiler infrastructure, popularized by the use of Abstract Syntax Trees, and recently projects such as MLIR have further explored Direct Acyclic Graphs. This project formalizes a Hypergraph IR with native semantics for higher-order applications such as:

YAML has the advantage of being a widely known syntax that is implemented in all programming languages. NetworkX enables seamless collaboration between graph libraries. We can implement all sorts of document transformations, leveraging a large ecosystem of software and well-known algorithms for complex networks.

Implementation

This project implements the PyYAML yaml.compose and yaml.serialize APIs using the NetworkX graph library. compose takes text input and converts it to a graph, while serialize does the inverse operation. Understanding this data structure is key to create portable and correct tooling for YAML, moving freely between text-based and code representations.

Check out the notebook tutorial. We use NxSafeLoader and NxSafeDumper with the PyYAML yaml.compose and yaml.serialize APIs.

Milestone 1

  1. Copy and paste from PyYAML
  2. Replace uses of nodes with NetworkX
  3. Publish a drop-in pip replacement

Milestone 2

  1. Compare performance
  2. Compare alignment with spec
  3. Share findings

Development environment

This is work in progress. pypi is updated on demand.

The development environment is self-contained using the pipenv tool.

Testing

  • Just pytest
  • Store graphs in resources/tests