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

Add bidirectional edge mode #133

Open
nrabinowitz opened this issue Aug 25, 2018 · 3 comments
Open

Add bidirectional edge mode #133

nrabinowitz opened this issue Aug 25, 2018 · 3 comments
Milestone

Comments

@nrabinowitz
Copy link
Collaborator

It occurred to me that it would be trivial to add a bidirectional edge mode (I would have preferred "directed" and "undirected", but we already have "unidirectional"), just by taking the unidirectional edge of the lower H3 index in a given pair of cells. I don't have use cases in mind yet, but it seems like a useful primitive, and it's simple to implement on top of the unidirectional functions.

If we had a more efficient version of getH3UnidirectionalEdgeBoundary this might allow an even simpler optimization for h3SetToLinkedGeo than vertex mode.

@dfellis
Copy link
Collaborator

dfellis commented Aug 25, 2018

Yep! Making the smaller index the first one is a good solution. Validating these bidirectional edges should also mark an inverted form as invalid.

A more efficient uni/bidirectional edge also would need to understand icosahedron face IJK rotations to determine the proper direction number when dealing with hexagons on the "edge" (which will depend on the res 0 parent owning icosahedron, not the icosahedron it is physically on).

Given those complexities I am not convinced a more efficient algorithm would be significantly more efficient.

@nrabinowitz
Copy link
Collaborator Author

Given those complexities I am not convinced a more efficient algorithm would be significantly more efficient.

True, but I'm actually more concerned about correctness. I don't think the current geoAlmostEqual approach will hold up at fine resolutions, where neighboring vertices falsely appear equal, or possibly at coarse resolutions, esp. near pentagons, where distortion might push vertices further apart than the threshold.

I don't actually think bidirectional edges will work in h3SetToLinkedGeo, because I would have trouble walking the graph if it wasn't keyed to the vertices - the optimization I have in mind probably still requires vertex mode. But it still seems like it's probably worth adding nonetheless.

@nrabinowitz
Copy link
Collaborator Author

This would now be called edge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants