graphcast.plot.plotter
¶
Graph visualization utilities for schema and data structures.
This module provides utilities for visualizing graph database schemas, relationships, and data structures using NetworkX and Graphviz. It includes functionality for plotting vertex collections, resources, and their relationships.
Key Components
- SchemaPlotter: Main class for schema visualization
- AuxNodeType: Enum for different node types in visualizations
- Color and shape mappings for different node types
- Tree assembly and graph generation utilities
Example
plotter = SchemaPlotter("config.json", "output/") plotter.plot_vc2fields() # Plot vertex collections and their fields plotter.plot_resources() # Plot resource relationships plotter.plot_vc2vc() # Plot vertex collection relationships
AuxNodeType
¶
Bases: BaseEnum
Node types for graph visualization.
This enum defines the different types of nodes that can appear in the visualization graphs, each with specific visual properties.
Attributes:
Name | Type | Description |
---|---|---|
FIELD |
Regular field node |
|
FIELD_DEFINITION |
Field definition node |
|
INDEX |
Index field node |
|
RESOURCE |
Resource node |
|
TRANSFORM |
Transform node |
|
VERTEX |
Vertex node |
|
VERTEX_BLANK |
Empty vertex node |
Source code in graphcast/plot/plotter.py
SchemaPlotter
¶
Main class for schema visualization.
This class provides methods to visualize different aspects of a graph database schema, including vertex collections, resources, and their relationships.
Attributes:
Name | Type | Description |
---|---|---|
fig_path |
Path to save visualizations |
|
config |
Schema configuration |
|
schema |
Schema instance |
|
name |
Schema name |
|
prefix |
Prefix for output files |
Source code in graphcast/plot/plotter.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
|
__init__(config_filename, fig_path)
¶
Initialize the schema plotter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_filename
|
Path to schema configuration file |
required | |
fig_path
|
Path to save visualizations |
required |
Source code in graphcast/plot/plotter.py
plot_resources()
¶
Plot resource relationships.
Creates visualizations for each resource in the schema, showing their internal structure and relationships. Each resource is saved as a separate PDF file.
Source code in graphcast/plot/plotter.py
plot_source2vc()
¶
Plot source to vertex collection mappings.
Creates a visualization showing the relationship between source resources and vertex collections. The visualization is saved as a PDF file.
Source code in graphcast/plot/plotter.py
plot_vc2fields()
¶
Plot vertex collections and their fields.
Creates a visualization showing the relationship between vertex collections and their fields, including index fields. The visualization is saved as a PDF file.
Source code in graphcast/plot/plotter.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
|
plot_vc2vc(prune_leaves=False)
¶
Plot vertex collection relationships.
Creates a visualization showing the relationships between vertex collections. Optionally prunes leaf nodes from the visualization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prune_leaves
|
Whether to remove leaf nodes from the visualization |
False
|
Example
plotter.plot_vc2vc(prune_leaves=True)
Source code in graphcast/plot/plotter.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
|
assemble_tree(aw, fig_path=None)
¶
Assemble a tree visualization from an actor wrapper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
aw
|
ActorWrapper
|
Actor wrapper containing the tree structure |
required |
fig_path
|
Optional[Path | str]
|
Optional path to save the visualization |
None
|
Returns:
Type | Description |
---|---|
Optional[nx.MultiDiGraph]: The assembled graph if fig_path is None |
Example
graph = assemble_tree(actor_wrapper) assemble_tree(actor_wrapper, "output/tree.pdf")
Source code in graphcast/plot/plotter.py
get_auxnode_id(ntype, label=False, vfield=False, **kwargs)
¶
Generate a unique identifier for an auxiliary node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ntype
|
AuxNodeType
|
Type of the auxiliary node |
required |
label
|
Whether to generate a label instead of an ID |
False
|
|
vfield
|
Whether this is a vertex field |
False
|
|
**kwargs
|
Additional parameters for node identification |
{}
|
Returns:
Name | Type | Description |
---|---|---|
str |
Node identifier or label |
Example
get_auxnode_id(AuxNodeType.VERTEX, vertex="user", label=True) 'user'
Source code in graphcast/plot/plotter.py
lto_dict(strings)
¶
Create a dictionary of string prefixes for shortening labels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strings
|
List of strings to process |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Mapping of shortened prefixes to original prefixes |
Example
lto_dict(["user", "user_profile", "user_settings"])