Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/traversal.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export foralledges
export foralledges, foralledgesupdatewts

"""
foralledges(f::Function, s::Stinger, v::Int64)
Expand All @@ -19,3 +19,29 @@ function foralledges(f::Function, s::Stinger, v::Int64)
current_eb_ptr = ebpool_priv_ptr + current_eb.next * (sizeof(StingerEdgeBlock) + sizeof(StingerEdge)*NUMEDGEBLOCKS);
end
end

"""
foralledgesupdatewts(s::Stinger, v::Int64, wts::Dict{Int64, Int64})

Iterates over all the edges edges of a vertex and increments the weights of the
edges if the neighbor is found in the `wts` dictionary, else leaves the weight
unchanged.
"""

function foralledgesupdatewts(s::Stinger, v::Int64, wts::Dict{Int64, Int64})
ebpool_priv_ptr = storageptr(s) + s[ebpool_start] * (sizeof(UInt8)) + sizeof(UInt64) * 2
current_eb_ptr = ebpool_priv_ptr + getvertex(s, v).edges * (sizeof(StingerEdgeBlock) + sizeof(StingerEdge)*NUMEDGEBLOCKS)
while current_eb_ptr != ebpool_priv_ptr
current_eb = unsafe_load(convert(Ptr{StingerEdgeBlock}, current_eb_ptr))
for i=1:current_eb.high
current_edge = unsafe_load(convert(Ptr{StingerEdge}, current_eb_ptr+sizeof(StingerEdgeBlock)), i)
direction, neighbor = edgeparse(current_edge)
edge_ptr = current_eb_ptr+sizeof(StingerEdgeBlock) + (i-1) * sizeof(StingerEdge)
unsafe_store!(
convert(Ptr{Int64}, edge_ptr + sizeof(Int64)),
current_edge.weight + get(wts, neighbor, 0)
)
end
current_eb_ptr = ebpool_priv_ptr + current_eb.next * (sizeof(StingerEdgeBlock) + sizeof(StingerEdge)*NUMEDGEBLOCKS);
end
end