@@ -279,17 +279,17 @@ end
279
279
nparts (g:: DGraph ) = with_state (g, nparts)
280
280
nparts (g:: DGraphState ) = length (g. parts)
281
281
Base. eltype (:: DGraph{T} ) where T = T
282
- Graphs. edgetype (:: DGraph{T} ) where T = Tuple{T, T}
282
+ Graphs. edgetype (:: DGraph{T} ) where T = Edge{ T}
283
283
Graphs. nv (g:: DGraph ) = with_state (g, nv):: Int
284
284
function Graphs. nv (g:: DGraphState )
285
285
if ! isempty (g. parts_nv)
286
- return last (g. parts_nv). stop
286
+ return Int ( last (g. parts_nv). stop)
287
287
else
288
288
return 0
289
289
end
290
290
end
291
291
Graphs. ne (g:: DGraph ) = with_state (g, ne):: Int
292
- Graphs. ne (g:: DGraphState ) = sum (g. parts_ne; init= 0 ) + sum (g. bg_adjs_ne_src; init= 0 )
292
+ Graphs. ne (g:: DGraphState ) = Int ( sum (g. parts_ne; init= 0 ) + sum (g. bg_adjs_ne_src; init= 0 ) )
293
293
Graphs. has_vertex (g:: DGraph , v:: Integer ) = 1 <= v <= nv (g)
294
294
Graphs. has_edge (g:: DGraph , edge:: Tuple ) = has_edge (g, edge[1 ], edge[2 ])
295
295
Graphs. has_edge (g:: DGraph , src:: Integer , dst:: Integer ) =
@@ -303,15 +303,17 @@ function Graphs.has_edge(g::DGraphState{T,D}, src::Integer, dst::Integer) where
303
303
if src_part_idx == dst_part_idx
304
304
# The edge will be within a graph partition
305
305
part = g. parts[src_part_idx]
306
- return exec_fast (has_edge, part, src, dst)
306
+ src_shift = src - (g. parts_nv[src_part_idx]. start - 1 )
307
+ dst_shift = dst - (g. parts_nv[dst_part_idx]. start - 1 )
308
+ return exec_fast (has_edge, part, src_shift, dst_shift)
307
309
else
308
310
# The edge will be in an AdjList
309
311
adj = g. bg_adjs[src_part_idx]
310
312
return exec_fast (has_edge, adj, src, dst)
311
313
end
312
314
end
313
315
Graphs. is_directed (:: DGraph{T,D} ) where {T,D} = D
314
- Graphs. vertices (g:: DGraph ) = Base. OneTo (nv (g))
316
+ Graphs. vertices (g:: DGraph{T} ) where T = Base. OneTo {T} (nv (g))
315
317
Graphs. edges (g:: DGraph ) = DGraphEdgeIter (g)
316
318
edges_with_metadata (f, g:: DGraph ) = DGraphEdgeIter (g; metadata= true , meta_f= f)
317
319
edges_with_weights (g:: DGraph ) = edges_with_metadata (weights, g)
@@ -357,8 +359,8 @@ function add_partition!(g::DGraphState{T,D}, n::Integer) where {T,D}
357
359
if n < 1
358
360
throw (ArgumentError (" n must be >= 1" ))
359
361
end
360
- push! (g. parts, Dagger. spawn (n) do n
361
- D ? SimpleDiGraph (n) : SimpleGraph (n)
362
+ push! (g. parts, Dagger. spawn (T, n) do T, n
363
+ D ? SimpleDiGraph {T} (n) : SimpleGraph {T} (n)
362
364
end )
363
365
num_v = nv (g)
364
366
push! (g. parts_nv, (num_v+ 1 ): (num_v+ n))
@@ -451,8 +453,8 @@ function Graphs.add_edge!(g::DGraphState{T,D}, src::Integer, dst::Integer) where
451
453
# Edge spans two partitions
452
454
src_bg_adj = g. bg_adjs[src_part_idx]
453
455
dst_bg_adj = g. bg_adjs[dst_part_idx]
454
- src_t = exec_fast (add_edge!, src_bg_adj, (src, dst); fetch = false )
455
- dst_t = exec_fast (add_edge!, dst_bg_adj, (src, dst); fetch = false )
456
+ src_t = exec_fast_nofetch (add_edge!, src_bg_adj, (src, dst))
457
+ dst_t = exec_fast_nofetch (add_edge!, dst_bg_adj, (src, dst))
456
458
if ! fetch (src_t) || ! fetch (dst_t)
457
459
return false
458
460
end
@@ -529,13 +531,13 @@ end
529
531
edge_owner (src:: Int , dst:: Int , src_part_idx:: Int , dst_part_idx:: Int ) =
530
532
iseven (hash (Base. unsafe_trunc (UInt, src+ dst))) ? src_part_idx : dst_part_idx
531
533
Graphs. inneighbors (g:: DGraph , v:: Integer ) = with_state (g, inneighbors, v)
532
- function Graphs. inneighbors (g:: DGraphState , v:: Integer )
534
+ function Graphs. inneighbors (g:: DGraphState{T} , v:: Integer ) where T
533
535
part_idx = findfirst (span-> v in span, g. parts_nv)
534
536
if part_idx === nothing
535
537
throw (BoundsError (g, v))
536
538
end
537
539
538
- neighbors = Int []
540
+ neighbors = T []
539
541
shift = g. parts_nv[part_idx]. start - 1
540
542
541
543
# Check against local edges
@@ -549,13 +551,13 @@ function Graphs.inneighbors(g::DGraphState, v::Integer)
549
551
return neighbors
550
552
end
551
553
Graphs. outneighbors (g:: DGraph , v:: Integer ) = with_state (g, outneighbors, v)
552
- function Graphs. outneighbors (g:: DGraphState , v:: Integer )
554
+ function Graphs. outneighbors (g:: DGraphState{T} , v:: Integer ) where T
553
555
part_idx = findfirst (span-> v in span, g. parts_nv)
554
556
if part_idx === nothing
555
557
throw (BoundsError (g, v))
556
558
end
557
559
558
- neighbors = Int []
560
+ neighbors = T []
559
561
shift = g. parts_nv[part_idx]. start - 1
560
562
561
563
# Check against local edges
0 commit comments