-
Notifications
You must be signed in to change notification settings - Fork 182
add neighborhood #329
add neighborhood #329
Conversation
Current coverage is
|
newneigs = Set{Int}() | ||
for i in ∂neig | ||
for j in fneig(g, i) | ||
if j ∉ neig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this test, since neig
is a set, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still need it because I wouldn't want to add to ∂neig
if it's already in neig
You're reading my mind, @CarloLucibello - I had plans to code this up this week. Looks good except for one question I had in the code (see the line notes). Other question: Couldn't you use BFS for this, or something like |
@sbromberger I was thinking the same thing. You could use a Visitor Type whose definition of if colormap[v] < d
# normal BFS behavior
else
# we have reached the d-th neighborhood break loop
return false
end This would give you the d-neighborhood without using Modifying the |
I don't think it is reasonable to have this local computation to scale with the size of the graph. Even if we reuse memory in the case of many calls, it would still be Could it be feasible to implement a "local" visitor? |
Just thinking out loud here - I think that if any of the |
Yeah that's right. We need to change the colormap to a sparse representation. Either a Dict or some AbstractArray. function breadth_first_visit_impl!(
graph::SimpleGraph, # the graph
queue::Vector{Int}, # an (initialized) queue that stores the active vertices
colormap::Vector{Int}, # an (initialized) color-map to indicate status of vertices
visitor::SimpleGraphVisitor) # the visitor The immutable LocalVisitor <: SimpleGraphVisitor
dists::Dict{Int, Int}
end We could also build egonets using the following visitor type. immutable EgonetVisitor{Graph} <: SimpleGraphVisitor
graph::Graph
dists::Dict{Int, Int}
end
immutable DiEgonetVisitor{Graph} <: SimpleGraphVisitor
graph::DiGraph
dists::Dict{Int, Int}
end |
closing this in favor of #332 |
neighborhood(g, v, d)
returns a vector containing the vertices ing
up to distanced
fromv
This is the most efficient version it come to me without thinking too hard on it. Any suggestion for improvements in performance and documentation is welcome
Also its positioning in connectivity.jl could be reconsidered