@@ -229,12 +229,20 @@ function sympermute!(
229229 index:: AbstractVector ,
230230 order:: Ordering ,
231231 ) where {V, E}
232- # validate arguments
233232 @argcheck vertices (graph) == vertices (result)
234233 @argcheck vertices (graph) == eachindex (index)
234+ count = Vector {E} (undef, nv (graph) + one (V))
235+ return sympermute! (count, result, graph, index, order)
236+ end
235237
238+ function sympermute! (
239+ count:: Vector{E} ,
240+ result:: BipartiteGraph{V, E} ,
241+ graph:: AbstractGraph ,
242+ index:: AbstractVector ,
243+ order:: Ordering ,
244+ ) where {V, E}
236245 # compute column counts
237- count = Vector {E} (undef, nv (graph) + one (V))
238246 count[one (V)] = one (E)
239247 count[two (V): (nv (graph) + one (V))] .= zero (E)
240248
@@ -286,9 +294,12 @@ function Base.reverse!(result::BipartiteGraph{V, E}, graph::AbstractGraph{V}) wh
286294 @argcheck nv (graph) == nov (result)
287295 @argcheck ne (graph) == ne (result)
288296 @argcheck nov (graph) == nv (result)
297+ count = Vector {E} (undef, nov (graph) + one (V))
298+ return reverse! (count, result, graph)
299+ end
289300
301+ function Base. reverse! (count:: Vector{E} , result:: BipartiteGraph{V, E} , graph:: AbstractGraph{V} ) where {V, E}
290302 # compute column counts
291- count = Vector {E} (undef, nov (graph) + one (V))
292303 count[one (V)] = one (E)
293304 count[two (V): (nov (graph) + one (V))] .= zero (E)
294305
@@ -444,12 +455,13 @@ function Graphs.vertices(graph::BipartiteGraph{V}) where {V}
444455 return oneto (nv (graph))
445456end
446457
447- @propagate_inbounds function Graphs. outneighbors (
448- graph:: BipartiteGraph{<:Any, E} , i:: Integer
449- ) where {E}
458+ @propagate_inbounds function Graphs. outneighbors (graph:: BipartiteGraph{<:Any, E} , i:: I ) where {E, I <: Integer }
459+ ii = i + one (I)
450460 @boundscheck checkbounds (pointers (graph), i)
451- @boundscheck checkbounds (pointers (graph), i + 1 )
452- return @inbounds @view targets (graph)[pointers (graph)[i]: (pointers (graph)[i + 1 ] - one (E))]
461+ @boundscheck checkbounds (pointers (graph), ii)
462+ @inbounds p = pointers (graph)[i]
463+ @inbounds pp = pointers (graph)[ii]
464+ return @view targets (graph)[p: (pp - one (E))]
453465end
454466
455467# slow
@@ -459,23 +471,24 @@ function Graphs.inneighbors(graph::BipartiteGraph, i::Integer)
459471 end
460472end
461473
462- @propagate_inbounds function Graphs. outdegree (
463- graph:: BipartiteGraph{V} , i:: Integer
464- ) where {V}
474+ @propagate_inbounds function Graphs. outdegree (graph:: BipartiteGraph , i:: I ) where {I <: Integer }
475+ ii = i + one (I)
465476 @boundscheck checkbounds (pointers (graph), i)
466- @boundscheck checkbounds (pointers (graph), i + 1 )
467- @inbounds n:: V = pointers (graph)[i + 1 ] - pointers (graph)[i]
477+ @boundscheck checkbounds (pointers (graph), ii)
478+ @inbounds p = pointers (graph)[i]
479+ @inbounds pp = pointers (graph)[ii]
480+ n:: Int = pp - p
468481 return n
469482end
470483
471484# slow
472485function Graphs. indegree (graph:: BipartiteGraph{V} , i:: Integer ) where {V}
473- n:: V = sum (j -> has_edge (graph, j, i), vertices (graph))
486+ n:: Int = sum (j -> has_edge (graph, j, i), vertices (graph))
474487 return n
475488end
476489
477- function Graphs. Δout (graph:: BipartiteGraph{V} ) where {V}
478- return maximum (vertices (graph); init = zero (V) ) do i
490+ function Graphs. Δout (graph:: BipartiteGraph )
491+ return maximum (vertices (graph); init = 0 ) do i
479492 outdegree (graph, i)
480493 end
481494end
0 commit comments