File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -509,7 +509,19 @@ sparse(g::AbstractGraph) = adjacency_matrix(g)
509
509
510
510
length (g:: AbstractGraph ) = widen (nv (g)) * widen (nv (g))
511
511
ndims (g:: AbstractGraph ) = 2
512
- issymmetric (g:: AbstractGraph ) = ! is_directed (g)
512
+
513
+ @traitfn function issymmetric (g:: AG ) where {AG <: AbstractGraph ; ! IsDirected{AG}}
514
+ return true
515
+ end
516
+
517
+ @traitfn function issymmetric (g:: AG ) where {AG <: AbstractGraph ; IsDirected{AG}}
518
+ for e in edges (g)
519
+ if ! has_edge (g, reverse (e))
520
+ return false
521
+ end
522
+ end
523
+ return true
524
+ end
513
525
514
526
"""
515
527
cartesian_product(g, h)
Original file line number Diff line number Diff line change 203
203
@test @inferred (! issymmetric (g))
204
204
end
205
205
206
+ gx = SimpleDiGraph (4 )
207
+ add_edge! (gx, 1 , 2 )
208
+ add_edge! (gx, 2 , 1 )
209
+ add_edge! (gx, 1 , 3 )
210
+ add_edge! (gx, 3 , 1 )
211
+ @testset " Matrix operations: $g " for g in testdigraphs (gx)
212
+ @test @inferred (issymmetric (g))
213
+ end
214
+
206
215
nx = 20
207
216
ny = 21
208
217
@testset " Cartesian Product / Crosspath: $g " for g in testlargegraphs (path_graph (ny))
You can’t perform that action at this time.
0 commit comments