graphcast.cli.plot_schema
¶
Schema visualization tool for graph databases.
This module provides functionality for visualizing graph database schemas using Graphviz. It includes tools for plotting vertex-to-vertex relationships, vertex fields, and resource mappings. The module supports various visualization options and graph layout customization.
Key Components
- SchemaPlotter: Main class for schema visualization
- knapsack: Utility for optimizing graph layout
- plot_schema: CLI command for schema visualization
Graphviz Attributes Reference
Example
plot_schema(schema_path="schema.yaml", figure_output_path="schema.png")
knapsack(weights, ks_size=7)
¶
Split a set of weights into groups of at most threshold weight.
This function implements a greedy algorithm to partition weights into groups where each group's total weight is at most ks_size. It's used for optimizing graph layout by balancing node distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
weights
|
List of weights to partition |
required | |
ks_size
|
Maximum total weight per group (default: 7) |
7
|
Returns:
Type | Description |
---|---|
list[list[int]]: List of groups, where each group is a list of indices from the original weights list |
Raises:
Type | Description |
---|---|
ValueError
|
If any single weight exceeds ks_size |
Example
weights = [3, 4, 2, 5, 1] knapsack(weights, ks_size=7) [[4, 0, 2], [1, 3]] # Groups with weights [6, 7]
Source code in graphcast/cli/plot_schema.py
plot_schema(schema_path, figure_output_path, prune_low_degree_nodes)
¶
Generate visualizations of the graph database schema.
This command creates multiple visualizations of the schema: 1. Vertex-to-vertex relationships 2. Vertex fields and their relationships 3. Resource mappings
The visualizations are saved to the specified output path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema_path
|
Path to the schema configuration file |
required | |
figure_output_path
|
Path where the visualization will be saved |
required | |
prune_low_degree_nodes
|
Whether to remove nodes with low connectivity from the visualization (default: False) |
required |
Example
$ uv run plot_schema -c schema.yaml -o schema.png