graphizy


Namegraphizy JSON
Version 0.1.4 PyPI version JSON
download
home_pagehttps://github.com/lesptizami/graphizy
SummaryA graph maker for computational geometry and network visualization
upload_time2025-07-10 01:30:03
maintainerNone
docs_urlNone
authorCharles Fosseprez
requires_python>=3.8
licenseMIT
keywords graph delaunay triangulation visualization computational-geometry
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Graphizy

A powerful graph maker for computational geometry and network visualization, specializing in Delaunay triangulation and proximity graphs.


![Detection to Graph](https://raw.githubusercontent.com/lesptizami/graphizy/main/images/detection_to_graph.png)

*Figure: Positions are converted to a graph in just a few milliseconds for hundreds of individuals using OpenCV.  
Graph analytics are accessible in real time as well, by interfacing with igraph.*

## Features

### Graph construction
- **Delaunay Triangulation**: Create optimal triangular meshes from point sets
- **Proximity Graphs**: Connect nearby points based on distance thresholds  
- **Collision Graphs**: Connect points based on history of collisions
### Graph Analysis
- **Igraph based**: https://igraph.org/python/tutorial/0.9.7/analysis.html
- **Comprehensive API**: Call any igraph method safely with error handling
### Design
- **Flexible Configuration**: Runtime-configurable parameters using dataclasses
- **Multiple Output Formats**: Save graphs as images or display interactively
- **Command Line Interface**: Easy-to-use CLI for common operations
- **Robust Error Handling**: Detailed exceptions and validation
- **Performance Monitoring**: Built-in timing and optimization tracking

## Installation

```bash
pip install graphizy
```

Or for development:

```bash
git clone https://github.com/cfosseprez/graphizy.git
cd graphizy
pip install -e .
```

## Quick Start

### Python API

```python
import numpy as np
from graphizy import Graphing, generate_positions

# Generate random points
positions = generate_positions(800, 800, 100)
particle_ids = np.arange(len(positions))
data = np.column_stack((particle_ids, positions))

# Create grapher
grapher = Graphing(dimension=(800, 800))

# Create Delaunay triangulation
delaunay_graph = grapher.make_delaunay(data)

# Create proximity graph
proximity_graph = grapher.make_proximity(data, proximity_thresh=50.0)

# Draw and save
delaunay_image = grapher.draw_graph(delaunay_graph)
grapher.save_graph(delaunay_image, "delaunay.jpg")

# Get graph statistics
info = grapher.get_graph_info(delaunay_graph)
print(f"Vertices: {info['vertex_count']}, Edges: {info['edge_count']}")
```

### Command Line Interface

```bash
# Create Delaunay triangulation
graphizy delaunay --size 800 --particles 100 --output delaunay.jpg --show

# Create proximity graph  
graphizy proximity --size 800 --particles 100 --threshold 50 --output proximity.jpg

# Create both and compare
graphizy both --size 1000 --particles 150 --threshold 40 --show

# Get detailed statistics
graphizy info --size 800 --particles 100 --output stats.json
```

## Configuration

Graphizy uses dataclasses for configuration that can be modified at runtime:

```python
from graphizy import GraphizyConfig, Graphing

# Create custom configuration
config = GraphizyConfig()
config.drawing.line_color = (255, 0, 0)  # Red lines
config.drawing.point_radius = 12
config.graph.proximity_threshold = 75.0

# Create grapher with config
grapher = Graphing(config=config)

# Update configuration at runtime
grapher.update_config(
    drawing={"line_thickness": 3},
    graph={"dimension": (1200, 1200)}
)
```

### Configuration Options

#### Drawing Configuration
- `line_color`: Line color as (B, G, R) tuple
- `line_thickness`: Line thickness in pixels
- `point_color`: Point color as (B, G, R) tuple  
- `point_thickness`: Point outline thickness
- `point_radius`: Point radius in pixels

#### Graph Configuration  
- `dimension`: Canvas size as (width, height)
- `data_shape`: Data structure definition
- `aspect`: Data format ("array" or "dict")
- `proximity_threshold`: Distance threshold for proximity graphs
- `distance_metric`: Distance metric ("euclidean", "manhattan", etc.)

## Advanced Usage

### Custom Data Structures

```python
from graphizy import Graphing, DataInterface

# Define custom data structure
data_shape = [
    ("particle_id", int),
    ("position_x", float), 
    ("position_y", float),
    ("velocity", float),
    ("mass", float)
]

grapher = Graphing(data_shape=data_shape)
```

### Calling Any igraph Method

```python
# Call any igraph method safely
vertex_count = grapher.call_method(graph, 'vcount')
degree_sequence = grapher.call_method(graph, 'degree')
clustering = grapher.call_method(graph, 'transitivity_undirected')

# Get comprehensive graph information  
info = grapher.get_graph_info(graph)
print(info)
```

### Error Handling

```python
from graphizy import GraphizyError, SubdivisionError

try:
    graph = grapher.make_delaunay(invalid_data)
except SubdivisionError as e:
    print(f"Triangulation failed: {e}")
except GraphizyError as e:
    print(f"Graph creation error: {e}")
```

## CLI Reference

### Commands

- `delaunay`: Create Delaunay triangulation
- `proximity`: Create proximity graph
- `both`: Create both graph types
- `info`: Generate statistics and analysis

### Common Options

- `--size SIZE`: Canvas size (default: 1200)
- `--particles N`: Number of points (default: 200)  
- `--output FILE`: Save image to file
- `--show`: Display graph interactively
- `--verbose`: Enable detailed logging
- `--config FILE`: Load configuration from JSON file

### Proximity Options

- `--threshold DIST`: Distance threshold (default: 50.0)
- `--metric METRIC`: Distance metric (default: euclidean)

### Styling Options

- `--line-color R,G,B`: Line color (default: 0,255,0)
- `--point-color R,G,B`: Point color (default: 0,0,255)
- `--line-thickness N`: Line thickness (default: 1)
- `--point-radius N`: Point radius (default: 8)

## Examples

### Configuration File

Create a JSON configuration file:

```json
{
  "drawing": {
    "line_color": [255, 0, 0],
    "line_thickness": 2,
    "point_radius": 10
  },
  "graph": {
    "dimension": [1024, 768],
    "proximity_threshold": 60.0
  },
  "generation": {
    "num_particles": 250
  }
}
```

Use with CLI:
```bash
graphizy both --config my_config.json --show
```

### Batch Processing

```python
import numpy as np
from graphizy import Graphing, generate_positions

grapher = Graphing(dimension=(600, 600))

for i in range(10):
    # Generate different datasets
    positions = generate_positions(600, 600, 50 + i*10)
    data = np.column_stack((np.arange(len(positions)), positions))
    
    # Create graphs
    delaunay_graph = grapher.make_delaunay(data)
    proximity_graph = grapher.make_proximity(data, proximity_thresh=30.0)
    
    # Save results
    del_image = grapher.draw_graph(delaunay_graph)
    prox_image = grapher.draw_graph(proximity_graph)
    
    grapher.save_graph(del_image, f"delaunay_{i:02d}.jpg")
    grapher.save_graph(prox_image, f"proximity_{i:02d}.jpg")
```

## API Reference

### Main Classes

- `Graphing`: Main class for graph creation and visualization
- `GraphizyConfig`: Configuration management
- `DataInterface`: Data format handling

### Key Functions

- `generate_positions()`: Generate random point distributions
- `make_subdiv()`: Create OpenCV subdivisions
- `get_distance()`: Calculate distance-based connections
- `call_igraph_method()`: Safe igraph method calling

### Drawing Functions

- `draw_point()`: Draw individual points
- `draw_line()`: Draw lines between points
- `show_graph()`: Display graphs interactively
- `save_graph()`: Save graphs to files

## Requirements

- Python >= 3.8
- NumPy >= 1.20.0
- OpenCV >= 4.5.0  
- python-igraph >= 0.9.0
- SciPy >= 1.7.0

## Development

### Running Tests

```bash
pip install pytest pytest-cov
pytest tests/ --cov=graphizy
```

### Code Style

```bash
pip install black flake8
black src/
flake8 src/
```

## License

MIT License - see LICENSE file for details.

## Contributing

1. Fork the repository
2. Create a feature branch
3. Add tests for new functionality  
4. Ensure all tests pass
5. Submit a pull request

## Author

**Charles Fosseprez**  
Email: charles.fosseprez.me@gmail.com

## Changelog

### v0.1.0
- Initial release
- Delaunay triangulation support
- Proximity graph creation
- Configurable drawing parameters
- Command line interface
- Comprehensive test suite
- Error handling and validation
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lesptizami/graphizy",
    "name": "graphizy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "graph, delaunay, triangulation, visualization, computational-geometry",
    "author": "Charles Fosseprez",
    "author_email": "charles.fosseprez.me@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9c/03/81fc19fe43ac0cfbb5f8d5ec11ce1dc48842b285ad66e61e0bf91673f619/graphizy-0.1.4.tar.gz",
    "platform": null,
    "description": "# Graphizy\n\nA powerful graph maker for computational geometry and network visualization, specializing in Delaunay triangulation and proximity graphs.\n\n\n![Detection to Graph](https://raw.githubusercontent.com/lesptizami/graphizy/main/images/detection_to_graph.png)\n\n*Figure: Positions are converted to a graph in just a few milliseconds for hundreds of individuals using OpenCV.  \nGraph analytics are accessible in real time as well, by interfacing with igraph.*\n\n## Features\n\n### Graph construction\n- **Delaunay Triangulation**: Create optimal triangular meshes from point sets\n- **Proximity Graphs**: Connect nearby points based on distance thresholds  \n- **Collision Graphs**: Connect points based on history of collisions\n### Graph Analysis\n- **Igraph based**: https://igraph.org/python/tutorial/0.9.7/analysis.html\n- **Comprehensive API**: Call any igraph method safely with error handling\n### Design\n- **Flexible Configuration**: Runtime-configurable parameters using dataclasses\n- **Multiple Output Formats**: Save graphs as images or display interactively\n- **Command Line Interface**: Easy-to-use CLI for common operations\n- **Robust Error Handling**: Detailed exceptions and validation\n- **Performance Monitoring**: Built-in timing and optimization tracking\n\n## Installation\n\n```bash\npip install graphizy\n```\n\nOr for development:\n\n```bash\ngit clone https://github.com/cfosseprez/graphizy.git\ncd graphizy\npip install -e .\n```\n\n## Quick Start\n\n### Python API\n\n```python\nimport numpy as np\nfrom graphizy import Graphing, generate_positions\n\n# Generate random points\npositions = generate_positions(800, 800, 100)\nparticle_ids = np.arange(len(positions))\ndata = np.column_stack((particle_ids, positions))\n\n# Create grapher\ngrapher = Graphing(dimension=(800, 800))\n\n# Create Delaunay triangulation\ndelaunay_graph = grapher.make_delaunay(data)\n\n# Create proximity graph\nproximity_graph = grapher.make_proximity(data, proximity_thresh=50.0)\n\n# Draw and save\ndelaunay_image = grapher.draw_graph(delaunay_graph)\ngrapher.save_graph(delaunay_image, \"delaunay.jpg\")\n\n# Get graph statistics\ninfo = grapher.get_graph_info(delaunay_graph)\nprint(f\"Vertices: {info['vertex_count']}, Edges: {info['edge_count']}\")\n```\n\n### Command Line Interface\n\n```bash\n# Create Delaunay triangulation\ngraphizy delaunay --size 800 --particles 100 --output delaunay.jpg --show\n\n# Create proximity graph  \ngraphizy proximity --size 800 --particles 100 --threshold 50 --output proximity.jpg\n\n# Create both and compare\ngraphizy both --size 1000 --particles 150 --threshold 40 --show\n\n# Get detailed statistics\ngraphizy info --size 800 --particles 100 --output stats.json\n```\n\n## Configuration\n\nGraphizy uses dataclasses for configuration that can be modified at runtime:\n\n```python\nfrom graphizy import GraphizyConfig, Graphing\n\n# Create custom configuration\nconfig = GraphizyConfig()\nconfig.drawing.line_color = (255, 0, 0)  # Red lines\nconfig.drawing.point_radius = 12\nconfig.graph.proximity_threshold = 75.0\n\n# Create grapher with config\ngrapher = Graphing(config=config)\n\n# Update configuration at runtime\ngrapher.update_config(\n    drawing={\"line_thickness\": 3},\n    graph={\"dimension\": (1200, 1200)}\n)\n```\n\n### Configuration Options\n\n#### Drawing Configuration\n- `line_color`: Line color as (B, G, R) tuple\n- `line_thickness`: Line thickness in pixels\n- `point_color`: Point color as (B, G, R) tuple  \n- `point_thickness`: Point outline thickness\n- `point_radius`: Point radius in pixels\n\n#### Graph Configuration  \n- `dimension`: Canvas size as (width, height)\n- `data_shape`: Data structure definition\n- `aspect`: Data format (\"array\" or \"dict\")\n- `proximity_threshold`: Distance threshold for proximity graphs\n- `distance_metric`: Distance metric (\"euclidean\", \"manhattan\", etc.)\n\n## Advanced Usage\n\n### Custom Data Structures\n\n```python\nfrom graphizy import Graphing, DataInterface\n\n# Define custom data structure\ndata_shape = [\n    (\"particle_id\", int),\n    (\"position_x\", float), \n    (\"position_y\", float),\n    (\"velocity\", float),\n    (\"mass\", float)\n]\n\ngrapher = Graphing(data_shape=data_shape)\n```\n\n### Calling Any igraph Method\n\n```python\n# Call any igraph method safely\nvertex_count = grapher.call_method(graph, 'vcount')\ndegree_sequence = grapher.call_method(graph, 'degree')\nclustering = grapher.call_method(graph, 'transitivity_undirected')\n\n# Get comprehensive graph information  \ninfo = grapher.get_graph_info(graph)\nprint(info)\n```\n\n### Error Handling\n\n```python\nfrom graphizy import GraphizyError, SubdivisionError\n\ntry:\n    graph = grapher.make_delaunay(invalid_data)\nexcept SubdivisionError as e:\n    print(f\"Triangulation failed: {e}\")\nexcept GraphizyError as e:\n    print(f\"Graph creation error: {e}\")\n```\n\n## CLI Reference\n\n### Commands\n\n- `delaunay`: Create Delaunay triangulation\n- `proximity`: Create proximity graph\n- `both`: Create both graph types\n- `info`: Generate statistics and analysis\n\n### Common Options\n\n- `--size SIZE`: Canvas size (default: 1200)\n- `--particles N`: Number of points (default: 200)  \n- `--output FILE`: Save image to file\n- `--show`: Display graph interactively\n- `--verbose`: Enable detailed logging\n- `--config FILE`: Load configuration from JSON file\n\n### Proximity Options\n\n- `--threshold DIST`: Distance threshold (default: 50.0)\n- `--metric METRIC`: Distance metric (default: euclidean)\n\n### Styling Options\n\n- `--line-color R,G,B`: Line color (default: 0,255,0)\n- `--point-color R,G,B`: Point color (default: 0,0,255)\n- `--line-thickness N`: Line thickness (default: 1)\n- `--point-radius N`: Point radius (default: 8)\n\n## Examples\n\n### Configuration File\n\nCreate a JSON configuration file:\n\n```json\n{\n  \"drawing\": {\n    \"line_color\": [255, 0, 0],\n    \"line_thickness\": 2,\n    \"point_radius\": 10\n  },\n  \"graph\": {\n    \"dimension\": [1024, 768],\n    \"proximity_threshold\": 60.0\n  },\n  \"generation\": {\n    \"num_particles\": 250\n  }\n}\n```\n\nUse with CLI:\n```bash\ngraphizy both --config my_config.json --show\n```\n\n### Batch Processing\n\n```python\nimport numpy as np\nfrom graphizy import Graphing, generate_positions\n\ngrapher = Graphing(dimension=(600, 600))\n\nfor i in range(10):\n    # Generate different datasets\n    positions = generate_positions(600, 600, 50 + i*10)\n    data = np.column_stack((np.arange(len(positions)), positions))\n    \n    # Create graphs\n    delaunay_graph = grapher.make_delaunay(data)\n    proximity_graph = grapher.make_proximity(data, proximity_thresh=30.0)\n    \n    # Save results\n    del_image = grapher.draw_graph(delaunay_graph)\n    prox_image = grapher.draw_graph(proximity_graph)\n    \n    grapher.save_graph(del_image, f\"delaunay_{i:02d}.jpg\")\n    grapher.save_graph(prox_image, f\"proximity_{i:02d}.jpg\")\n```\n\n## API Reference\n\n### Main Classes\n\n- `Graphing`: Main class for graph creation and visualization\n- `GraphizyConfig`: Configuration management\n- `DataInterface`: Data format handling\n\n### Key Functions\n\n- `generate_positions()`: Generate random point distributions\n- `make_subdiv()`: Create OpenCV subdivisions\n- `get_distance()`: Calculate distance-based connections\n- `call_igraph_method()`: Safe igraph method calling\n\n### Drawing Functions\n\n- `draw_point()`: Draw individual points\n- `draw_line()`: Draw lines between points\n- `show_graph()`: Display graphs interactively\n- `save_graph()`: Save graphs to files\n\n## Requirements\n\n- Python >= 3.8\n- NumPy >= 1.20.0\n- OpenCV >= 4.5.0  \n- python-igraph >= 0.9.0\n- SciPy >= 1.7.0\n\n## Development\n\n### Running Tests\n\n```bash\npip install pytest pytest-cov\npytest tests/ --cov=graphizy\n```\n\n### Code Style\n\n```bash\npip install black flake8\nblack src/\nflake8 src/\n```\n\n## License\n\nMIT License - see LICENSE file for details.\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Add tests for new functionality  \n4. Ensure all tests pass\n5. Submit a pull request\n\n## Author\n\n**Charles Fosseprez**  \nEmail: charles.fosseprez.me@gmail.com\n\n## Changelog\n\n### v0.1.0\n- Initial release\n- Delaunay triangulation support\n- Proximity graph creation\n- Configurable drawing parameters\n- Command line interface\n- Comprehensive test suite\n- Error handling and validation",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A graph maker for computational geometry and network visualization",
    "version": "0.1.4",
    "project_urls": {
        "Homepage": "https://github.com/lesptizami/graphizy",
        "Issues": "https://github.com/lesptizami/graphizy/issues",
        "Repository": "https://github.com/lesptizami/graphizy"
    },
    "split_keywords": [
        "graph",
        " delaunay",
        " triangulation",
        " visualization",
        " computational-geometry"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f1f42a11833e548b6f974ff249c1010eaa56469a6012fde4b6d1efdf1340bdeb",
                "md5": "25eb5c98f52e3936a54733ccb2aab60d",
                "sha256": "53e3ff74d884b8d05f7bd05df1e13d18f4d1123e96e450ccb9eb05ca78b92bc1"
            },
            "downloads": -1,
            "filename": "graphizy-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "25eb5c98f52e3936a54733ccb2aab60d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 25849,
            "upload_time": "2025-07-10T01:30:01",
            "upload_time_iso_8601": "2025-07-10T01:30:01.996759Z",
            "url": "https://files.pythonhosted.org/packages/f1/f4/2a11833e548b6f974ff249c1010eaa56469a6012fde4b6d1efdf1340bdeb/graphizy-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9c0381fc19fe43ac0cfbb5f8d5ec11ce1dc48842b285ad66e61e0bf91673f619",
                "md5": "1cb883b90be8b6b3e64f02a6d20323fb",
                "sha256": "56a9da76c63253b16b1b031278811dbb6e6dba368458b97437eb0795b5a5e2dd"
            },
            "downloads": -1,
            "filename": "graphizy-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "1cb883b90be8b6b3e64f02a6d20323fb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 34465,
            "upload_time": "2025-07-10T01:30:03",
            "upload_time_iso_8601": "2025-07-10T01:30:03.699482Z",
            "url": "https://files.pythonhosted.org/packages/9c/03/81fc19fe43ac0cfbb5f8d5ec11ce1dc48842b285ad66e61e0bf91673f619/graphizy-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-10 01:30:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lesptizami",
    "github_project": "graphizy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "graphizy"
}
        
Elapsed time: 0.57256s