Simplificacion de grafos urbanos y analisis de criminalidad
Project description
ACJ: Urban Graph Acceleration & Simplification Framework
ACJ is a high-performance hybrid C++/Python framework for the semantic and topological simplification of large-scale urban street networks. It safely decouples topology from semantic metadata (speed limits, road names, etc.) so that both survive massive graph reductions powered by a CGAL-accelerated C++ core.
Installation
ACJ is published on PyPI and ships with pre-compiled wheels for Linux, macOS (Apple Silicon & Intel), and Windows. No C++ compilation required.
pip install acj
For GPU-accelerated real-time visualization, install the optional extras:
pip install "acj[viz]"
We recommend working inside a virtual environment:
python -m venv venv && source venv/bin/activate
Quick Start — End-to-End Pipeline
import osmnx as ox
from acj import UrbanNetwork, ACJTopologicalEvaluator
from acj import CompressionRatioMetric, SemanticSpeedDistortionMetric
# 1. Fetch a raw street network
G = ox.graph_from_place("Barranco, Lima, Peru", network_type="drive")
# 2. Parse into the ACJ registry
network = UrbanNetwork.from_networkx(G)
print(network)
# <UrbanNetwork | Nodes: 312 (Meta: True) | Edges: 847 (Meta: True)>
# 3. Configure metrics and run the evaluator
metrics = [CompressionRatioMetric(), SemanticSpeedDistortionMetric()]
evaluator = ACJTopologicalEvaluator(network, metrics)
results = evaluator.evaluate()
print(results)
print(evaluator.simplified_network)
API Reference
UrbanNetwork — Core Data Container
The central data structure. Stores topology in Pandas DataFrames and semantic attributes in dictionaries, keeping them decoupled for safe C++ operations.
from acj import UrbanNetwork
# From an OSMnx / NetworkX graph
network = UrbanNetwork.from_networkx(G)
# From raw DataFrames
# nodes_df must have columns: node_id, x, y (+ any metadata columns)
# edges_df must have columns: segment_id, node_start, node_end (+ any metadata columns)
network = UrbanNetwork.from_dataframe(nodes_df, edges_df)
Key attributes:
| Attribute | Type | Description |
|---|---|---|
nodes_df |
pd.DataFrame |
Node topology: node_id, x, y |
edges_df |
pd.DataFrame |
Edge topology: segment_id, node_start, node_end |
node_metadata |
dict |
Per-node semantic attributes keyed by node_id |
edge_metadata |
dict |
Per-edge semantic attributes keyed by segment_id |
MapIndex — Spatial Queries
CGAL-backed spatial index for fast nearest-neighbor point-to-graph assignment. Useful for correlating events (e.g., crime incidents) with street segments or intersections.
from acj import MapIndex, load_graph
import pandas as pd
graph_data = load_graph(nodes_df, edges_df)
index = MapIndex(graph_data)
# Assign point events to the nearest node
points = pd.DataFrame({'point_id': [1, 2], 'x': [-77.02, -77.03], 'y': [-12.15, -12.14]})
node_assignments = index.assign_to_endpoints(points)
# Returns original DataFrame + 'assigned_node_id' and 'distance' columns
# Assign point events to the nearest edge segment
segment_assignments = index.assign_to_segments(points)
# Returns original DataFrame + 'assigned_segment_id' and 'distance' columns
ACJTopologicalEvaluator — Simplification Lifecycle
Automates the full pipeline: injects the network into the C++ core, receives the simplified topology with lineage maps, runs semantic resolution, and applies metrics.
from acj import ACJTopologicalEvaluator, CompressionRatioMetric, SemanticSpeedDistortionMetric
evaluator = ACJTopologicalEvaluator(network, metrics=[
CompressionRatioMetric(),
SemanticSpeedDistortionMetric(),
])
results = evaluator.evaluate()
simplified = evaluator.simplified_network # UrbanNetwork
Built-in metrics:
| Class | Measures |
|---|---|
CompressionRatioMetric |
Node/edge reduction ratio after simplification |
SemanticSpeedDistortionMetric |
Speed-limit distribution distortion introduced by edge merging |
Visualization (optional viz extra)
GPU-accelerated interactive tools built on VisPy/OpenGL. Requires pip install "acj[viz]".
from acj import MapIndex, load_graph
from acj import render_graph, render_heatmap, render_comparison
graph_data = load_graph(nodes_df, edges_df)
index = MapIndex(graph_data)
# Render the raw street network
render_graph(index)
# Render a heatmap of point assignments over the network
render_heatmap(index, assignments=node_assignments)
# Side-by-side comparison of two networks (e.g., original vs. simplified)
render_comparison(
index_original, index_simplified,
title_left="Original", title_right="Simplified"
)
Interactive controls (all render functions):
| Key | Action |
|---|---|
N |
Toggle node layer |
L |
Toggle segment layer |
G |
Toggle grid |
R |
Reset camera view |
Q / Esc |
Close window |
load_graph / load_map — Data IO
from acj import load_graph, load_map
# Build a GraphData object from DataFrames (required input for MapIndex)
graph_data = load_graph(nodes_df, edges_df)
# Load from a file path (GeoJSON, Shapefile, etc.)
graph_data = load_map("path/to/network.geojson")
Developer Installation (From Source)
Required: CMake ≥ 3.15, C++17, CGAL, Boost, pybind11.
# Ubuntu/Debian
sudo apt-get install cmake libcgal-dev libboost-all-dev
# Arch Linux
sudo pacman -S cmake cgal boost pybind11
git clone https://github.com/CdeCasurpie/CS5351-acj.git
cd CS5351-acj
python -m venv venv && source venv/bin/activate
pip install -U pip setuptools wheel
pip install -e .
Academic Team & Acknowledgements
This framework was developed as part of a thesis research project at the Universidad de Ingeniería y Tecnología (UTEC).
Lead Researchers & Engineers:
- Alejandro Calizaya
- Cesar Perales
- Jerimy Sandoval
Thesis Advisors:
- Eric Javier Biagioli - Academic Director, Department of Computer and Data Science, UTEC (ORCID: 0009-0000-2027-0647)
- Germain García Zanabria - Researcher, Artificial Intelligence Research Group (GINIA), UTEC (ORCID: 0000-0003-3266-9043)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file acj-0.1.4.tar.gz.
File metadata
- Download URL: acj-0.1.4.tar.gz
- Upload date:
- Size: 53.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa247565214faa82e980b5bf781d9c154a43e5298083927536f881f9273a7719
|
|
| MD5 |
3fd1b8632c17cc03901bc370ae9e3869
|
|
| BLAKE2b-256 |
1d1d7b2d7fb498b3f0fb93795a8e49f6f94295e815482e1a045f999207388df4
|
File details
Details for the file acj-0.1.4-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: acj-0.1.4-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b17a065d7ebe26155aa16e1251b8735e18e935eca017fb81d20b71ec29808273
|
|
| MD5 |
12c2d35d93e96be34cf67214d4b13d5f
|
|
| BLAKE2b-256 |
89f8d5712101143e4b8faa3bddbec932bd69127ed3b75f9121db52a6090782c4
|
File details
Details for the file acj-0.1.4-cp313-cp313-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: acj-0.1.4-cp313-cp313-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.13, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dee7e8a3a213874a0699173115a59aad84b622becca443af94c515bbdebbe3d3
|
|
| MD5 |
a0ea5788b28b58b73ef24cab8ba8695d
|
|
| BLAKE2b-256 |
b25b54b37ce5103a8289c9084f6de76f091e9f67eaf40e62d7eb718e10fe1607
|
File details
Details for the file acj-0.1.4-cp313-cp313-macosx_26_0_arm64.whl.
File metadata
- Download URL: acj-0.1.4-cp313-cp313-macosx_26_0_arm64.whl
- Upload date:
- Size: 945.9 kB
- Tags: CPython 3.13, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a29cba78f335c61245ee69fe7a5156e7bd1d85f37bcc0719d3b225722e22885
|
|
| MD5 |
96830aa7b804e5b8a7458d9128540fb8
|
|
| BLAKE2b-256 |
bf833699a8297291bc132cdcdfcb539ed4f9276bb4a4a77f438f751e7d6a1817
|
File details
Details for the file acj-0.1.4-cp313-cp313-macosx_15_0_arm64.whl.
File metadata
- Download URL: acj-0.1.4-cp313-cp313-macosx_15_0_arm64.whl
- Upload date:
- Size: 919.1 kB
- Tags: CPython 3.13, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b77d6e2e9b72dc72e58538296a5998f5d154c78e77cbe5df4c4cdd0185628f9
|
|
| MD5 |
9d3793d6f796ce6656e17c344b9868f0
|
|
| BLAKE2b-256 |
842836a640b9cbd26cffda4089597fcec442e8d6037f4880f281e5b7a09ed782
|
File details
Details for the file acj-0.1.4-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: acj-0.1.4-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ccc96ad8db96f1fe01195aff09bb5877765ef70a7064d9d674bc5bf40a257b7
|
|
| MD5 |
36c9a5c99bcf98cb2fdfc777a5fffecc
|
|
| BLAKE2b-256 |
d1b3a7d6c156984a003e0c9a37d2a3c98f7af090b662f2fb0ff28a144f3f13ba
|
File details
Details for the file acj-0.1.4-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: acj-0.1.4-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d17f70822f3014f45d50aa9aa2a48ad1004110198029d85c3cd009ef73eb396
|
|
| MD5 |
1e09085ec9be3606f27b8e34db4b281a
|
|
| BLAKE2b-256 |
62a267268cf1e05bdabb0e124f3f314ff78462560beb7bd620dbd75a4b4e4015
|
File details
Details for the file acj-0.1.4-cp312-cp312-macosx_26_0_arm64.whl.
File metadata
- Download URL: acj-0.1.4-cp312-cp312-macosx_26_0_arm64.whl
- Upload date:
- Size: 945.7 kB
- Tags: CPython 3.12, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2248ae445ae86c017a2806095fd2e6062d74858e0e01f6c5c1ed86b384c9d43
|
|
| MD5 |
040b1409555e2c9c55119be817e9164e
|
|
| BLAKE2b-256 |
5aa6c2fa78a5dbe38e6742603d9914df7a31520a4b3dae8c4a1a3f86a3a7b633
|
File details
Details for the file acj-0.1.4-cp312-cp312-macosx_15_0_arm64.whl.
File metadata
- Download URL: acj-0.1.4-cp312-cp312-macosx_15_0_arm64.whl
- Upload date:
- Size: 919.1 kB
- Tags: CPython 3.12, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5a901c003c0ba0ac3a13556b3fdae367258adb31f1f05913ea6c97cdae5008d
|
|
| MD5 |
1028ba9faa542fd027b6bb4c95dd4c1f
|
|
| BLAKE2b-256 |
f44c44e6cc191fecdc2f841a35f798d4be2345f2643bd082ffeaa0b9036ebe02
|
File details
Details for the file acj-0.1.4-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: acj-0.1.4-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85dcc5a7858b49a02ecc9da1c05ed7771eaf1585f3a86e3b4201002dd6936071
|
|
| MD5 |
0e546e9922049d7a3c765066d1498d36
|
|
| BLAKE2b-256 |
ef001bd0cadf79774f692508d350fa80435abac44dddafc65580c6e13061f619
|
File details
Details for the file acj-0.1.4-cp311-cp311-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: acj-0.1.4-cp311-cp311-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
908135f0b1262581cb721867220fcdf31705ce84a9a86c3febfdd2819d33982a
|
|
| MD5 |
602f60fc6107cdeb1ee80fd70cec4966
|
|
| BLAKE2b-256 |
10149ae05fedea0d02221d7060c5c19b6f89f52e6ebe6da1b020a55412eb5df6
|
File details
Details for the file acj-0.1.4-cp311-cp311-macosx_26_0_arm64.whl.
File metadata
- Download URL: acj-0.1.4-cp311-cp311-macosx_26_0_arm64.whl
- Upload date:
- Size: 944.7 kB
- Tags: CPython 3.11, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b6867e37b0e75fc1f22d9a879c562cab7c2b89b3d271e4d8e86c8d506cd7ed2
|
|
| MD5 |
308253d2c8d2c770de58289332e2e432
|
|
| BLAKE2b-256 |
b5299043ac5f412a33f31ce3038f3cd4c2bf91d8a04fd6714096f1c8a1b68f56
|
File details
Details for the file acj-0.1.4-cp311-cp311-macosx_15_0_arm64.whl.
File metadata
- Download URL: acj-0.1.4-cp311-cp311-macosx_15_0_arm64.whl
- Upload date:
- Size: 918.2 kB
- Tags: CPython 3.11, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34af44ba52006e326726368457f6c0c013942baeb269ed9193b4539340d786d8
|
|
| MD5 |
5982e03601559edaac9594130f31720f
|
|
| BLAKE2b-256 |
2d9d3792f8976e864b60838d898bc1291feb0aad93374da48e16106e90432789
|
File details
Details for the file acj-0.1.4-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: acj-0.1.4-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d9ccd99974b9e570df82c27bfb65f3311f5957bc8253cfbe464f8a4fb5aed39
|
|
| MD5 |
ef6488ca442de277cd74525f41a69e4c
|
|
| BLAKE2b-256 |
be3de068343043422b0e0ce20b5286ad4f127c52f0cceb9ca332e40e1ffa3ba4
|
File details
Details for the file acj-0.1.4-cp310-cp310-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: acj-0.1.4-cp310-cp310-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d827d3e35852174bdcb0ec68788413e3213b409e0c928b801c4cf50317205a3
|
|
| MD5 |
cdf389fecf5325ade1343bde85908cf5
|
|
| BLAKE2b-256 |
9c427b6ba3a402acaa6d837d57a93e610d8d72648fac375d8e8ba7acacd81623
|
File details
Details for the file acj-0.1.4-cp310-cp310-macosx_26_0_arm64.whl.
File metadata
- Download URL: acj-0.1.4-cp310-cp310-macosx_26_0_arm64.whl
- Upload date:
- Size: 943.5 kB
- Tags: CPython 3.10, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f5e4c156ff0c22e873aad3c0ff3e048ccdaccf547c07c9b868396430d55af39
|
|
| MD5 |
b50fac5d5bec51902cf991c7da982059
|
|
| BLAKE2b-256 |
156280025e430dee1a7a403e7885954ea661349437b44f2549f1d340d006bcef
|
File details
Details for the file acj-0.1.4-cp310-cp310-macosx_15_0_arm64.whl.
File metadata
- Download URL: acj-0.1.4-cp310-cp310-macosx_15_0_arm64.whl
- Upload date:
- Size: 917.3 kB
- Tags: CPython 3.10, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b53959660fd575edaae1c0f84ec8a80782024eb0d2c9262998f0923f96a57bd1
|
|
| MD5 |
45801c2648d525b301450db520806b44
|
|
| BLAKE2b-256 |
d8c59b64152fd1d939799b07c7db695998379ca9c12360ba14b503ac2f1799a5
|