Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: misaligned weights in the gabriel graph #709

Merged
merged 2 commits into from
May 17, 2024

Conversation

martinfleis
Copy link
Member

Found a bug in Gabriel graph. heads and tails come unsorted from filtering, resulting in misaligned weights. See repr:

import geopandas
from libpysal.graph import Graph
import momepy

blgs = geopandas.read_file(momepy.datasets.get_path('bubenec'), layer='buildings')

delaunay = Graph.build_triangulation(blgs.centroid, "delaunay", kernel="identity")
gabriel = Graph.build_triangulation(blgs.centroid, "gabriel", kernel="identity")
relative = Graph.build_triangulation(blgs.centroid, "relative_neighborhood", kernel="identity")

>>> delaunay[48]
neighbor
46      24.357863
47      32.418353
49      49.764015
74     155.698588
75      99.914953
141     93.302955
Name: weight, dtype: float64

>>> gabriel[48]
neighbor
46    128.634198
47     24.117386
Name: weight, dtype: float64

>>> relative[48]
neighbor
46    24.357863
47    32.418353
Name: weight, dtype: float64

It should be a subset of Delaunay, not alter the value.

@ljwolf
Copy link
Member

ljwolf commented May 17, 2024

This looks okay to me!

Copy link

codecov bot commented May 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.9%. Comparing base (bcabdbc) to head (de59f61).
Report is 12 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #709     +/-   ##
=======================================
- Coverage   85.0%   84.9%   -0.1%     
=======================================
  Files        141     141             
  Lines      15203   15232     +29     
=======================================
+ Hits       12924   12926      +2     
- Misses      2279    2306     +27     
Files Coverage Δ
libpysal/graph/_triangulation.py 98.0% <100.0%> (+<0.1%) ⬆️
libpysal/graph/tests/test_builders.py 100.0% <100.0%> (ø)

... and 3 files with indirect coverage changes

@jGaboardi jGaboardi added bug functionality that: returns invalid, erroneous, or meaningless results; or doesn't work at all. graph labels May 17, 2024
@martinfleis martinfleis merged commit 6f783d0 into pysal:main May 17, 2024
11 checks passed
@martinfleis martinfleis deleted the gabriel_sort branch May 17, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug functionality that: returns invalid, erroneous, or meaningless results; or doesn't work at all. graph
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants