-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move tests to graphsextensions tests. Refactor function
- Loading branch information
Showing
3 changed files
with
13 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
using Graphs: AbstractGraph, neighborhood_dists | ||
|
||
function vertices_at_distance(g::AbstractGraph, vertex, n::Int) | ||
neighborhood = [first(v) for v in neighborhood_dists(g, vertex, n)] | ||
closer_neighborhood = [first(v) for v in neighborhood_dists(g, vertex, n - 1)] | ||
iszero(n) && return neighborhood | ||
return setdiff(neighborhood, closer_neighborhood) | ||
function vertices_at_distance(g::AbstractGraph, vertex, distance::Int) | ||
n_dists = neighborhood_dists(g, vertex, distance) | ||
return map(first, filter(==(distance) ∘ last, n_dists)) | ||
end | ||
|
||
next_nearest_neighbors(g::AbstractGraph, v) = vertices_at_distance(g, v, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.