Quick Start
A quick start guide to help you get started with Diamond.
Using Diamond
Diamond can be integrated into your workflows to compress and manage Labeled Property Graphs. The core component for this is the PropertyGraph class.
Basic Operations
To use Diamond, you'll typically import PropertyGraph and use its methods to read your existing graph data and write it out in the compressed .diamond format, or convert it to other supported formats.
Example: Compressing a PG_JSONL file to .diamond
In-Memory Representations
The PropertyGraph object also allows you to work with in-memory representations of your graph data. This is particularly useful for direct inspection or manipulation within your environment.
Key methods include:
pg.to_pg_json() -> PgJsonPropertyGraph: Converts the graph into an in-memory PG-JSON model. This representation, is ideal for examining the graph's structure and properties.pg.to_diamond() -> DiamondGraph: Transforms thePropertyGraphinto an in-memoryDiamondGraphobject. This format typically stores graph data using Polars DataFrames, offering efficient data manipulation capabilities.PropertyGraph.from_diamond(diamond_graph: DiamondGraph) -> PropertyGraph: Reconstructs aPropertyGraphinstance from an in-memoryDiamondGraphobject.
Example: Inspecting Graph Data via PG-JSON
Here's a more comprehensive example that ties together reading a graph, converting it to its PG-JSON representation, and then printing and inspecting this in-memory object.
How is this guide?