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

Implement is_articulation to check if vertex is articulation point #387

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

thchr
Copy link
Contributor

@thchr thchr commented Jun 19, 2024

This factors out the DFS step from articulation into a separate function articulation_dfs! and then uses this new function to implement is_articulation(g, v) which checks whether v is an articulation point of g without necessarily computing all the articulation points.

The branching on isnothing(is_articulation_pts) in articulation_dfs! is a bit inelegant - as is the fact that articulation_dfs! doesn't mutate if is_articulation_pts === nothing, but it seemed the simplest way to avoid code duplication.

Aside from these additions, I revised the doc string of articulation(g) a bit (e.g., it 1. previously misleadingly stated that g had to be connected; it does not; and 2. it changed nomenclature from "articulation point" to "cut vertex" mid-sentence).

@thchr
Copy link
Contributor Author

thchr commented Jun 19, 2024

Timing-wise, is_articulation(g, v) appears to give a speed-up of about a factor of ~2 in cases I looked at, compared to v ∈ articulation(g):

julia> g = path_graph(5)
julia> articulation(g) # [2, 3, 4]
julia> @btime 2  articulation($g)   # 209.656 ns (8 allocations: 704 bytes)
julia> @btime is_articulation($g, 2) # 122.850 ns (4 allocations: 464 bytes)

julia> g = path_graph(15)
julia> articulation(g) # [2:14...]
julia> @btime 9  articulation($g)   # 453.853 ns (10 allocations: 2.16 KiB)
julia> @btime is_articulation($g, 9) # 245.286 ns (4 allocations: 624 bytes)

Copy link

codecov bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 98.21429% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.30%. Comparing base (56e5604) to head (669093e).
Report is 4 commits behind head on master.

Files Patch % Lines
src/biconnectivity/articulation.jl 98.21% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #387      +/-   ##
==========================================
- Coverage   97.31%   97.30%   -0.02%     
==========================================
  Files         120      120              
  Lines        6954     6965      +11     
==========================================
+ Hits         6767     6777      +10     
- Misses        187      188       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gdalle gdalle added the enhancement New feature or request label Jun 26, 2024
@thchr
Copy link
Contributor Author

thchr commented Aug 26, 2024

Bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants