materialsvirtuallab / matgl

Graph deep learning library for materials
BSD 3-Clause "New" or "Revised" License
256 stars 59 forks source link

Directed line graph #178

Closed lbluque closed 1 year ago

lbluque commented 1 year ago

Summary

Implements constructing a directed line graph, where edges in the original graph have an edge in the line graph if the dst node of the first edge matches the src node of the second. i.e. the following directed edges x = (u,v) and y = (v,w) will have a directed edge in the line graph (x, y).

Implemented:

I had to adapt compute_theta to handle the "directed" case, bc in this case one of the bond vectors must be flipped to get the correct angle and not its complement.

Checklist

Tip: Install pre-commit hooks to auto-check types and linting before every commit:

pip install -U pre-commit
pre-commit install
codecov[bot] commented 1 year ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (13a5da2) 97.97% compared to head (e32faa7) 97.99%. Report is 1 commits behind head on main.

:exclamation: Current head e32faa7 differs from pull request most recent head 52d1e17. Consider uploading reports for the commit 52d1e17 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #178 +/- ## ========================================== + Coverage 97.97% 97.99% +0.01% ========================================== Files 28 28 Lines 1828 1891 +63 ========================================== + Hits 1791 1853 +62 - Misses 37 38 +1 ``` | [Files](https://app.codecov.io/gh/materialsvirtuallab/matgl/pull/178?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=materialsvirtuallab) | Coverage Δ | | |---|---|---| | [matgl/graph/compute.py](https://app.codecov.io/gh/materialsvirtuallab/matgl/pull/178?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=materialsvirtuallab#diff-bWF0Z2wvZ3JhcGgvY29tcHV0ZS5weQ==) | `99.22% <98.63%> (-0.78%)` | :arrow_down: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/materialsvirtuallab/matgl/pull/178/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=materialsvirtuallab)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

shyuep commented 1 year ago

I would actually do it by simply add a kwarg called is_directed to create_line_graph which defaults to False. It should be simple to do based on your current implementation.

lbluque commented 1 year ago

@shyuep made the changes you suggested, pls have a look when you can

shyuep commented 1 year ago

Thanks