Graph-Based Analysis#

Graph-based analysis provides tools for representing and analyzing relationships between drawing entities using graph structures.

Purpose#

This module enables the construction and analysis of various graph representations:

  • EdgeAdjacencyGraph: Represents adjacency relationships between edges in a drawing

  • GeometryDimensionGraph: Maps relationships between geometric entities and their dimensions

  • EdgeConstraintGraph: Represents constraint relationships between edges

These graphs are useful for:

  • Analyzing geometric relationships between drawing elements

  • Understanding how dimensions reference geometries

  • Detecting patterns and clusters in drawing structures

  • Validating geometric constraints

Note

Because development is ongoing, detailed documentation for graph-based analysis is not yet available. Please refer to the API Reference for available classes and methods in the drawing_tools.view.geometry.relationships module.

A working example is however available in scripts/view_graph.py.

Visualization#

Graph objects provide visualization methods to inspect their structure:

# EdgeAdjacencyGraph — open in browser
adjacency_graph.plot_data()

# EdgeAdjacencyGraph — graph-only rendering
adjacency_graph.plot_data_graph()

# GeometryDimensionGraph — graph rendering
geometry_dimension_graph.plot_data_graph()

Dimension Node Attributes#

GeometryDimensionGraph attaches the following parser-derived attributes to each dimension node (in addition to the standard visualization attributes name, shape, color, size):

  • main_value — nominal measurement (float | None)

  • has_toleranceTrue when a tolerance is present on the dimension

  • tolerance_kind — one of symmetric, unilateral_upper, unilateral_lower, bilateral, unknown, or None when there is no tolerance

  • prefix — optional prefix symbol (, R, …)

  • text_count — number of raw text fragments collected from the dimension

The on-canvas name label is composed as "{entity_type}\n{compact_label}" where compact_label is produced by build_compact_dimension_label() — a single-line {prefix} {main_value} {tolerance} formatter shared with other space-constrained renderings.