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.
You don't need this test, since neig is a set, right?
There was a problem hiding this comment.
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
endThis 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 visitorThe immutable LocalVisitor <: SimpleGraphVisitor
dists::Dict{Int, Int}
endWe 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 ingup to distancedfromvThis 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