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)
509509
510510length (g:: AbstractGraph ) = widen (nv (g)) * widen (nv (g))
511511ndims (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
513525
514526"""
515527 cartesian_product(g, h)
Original file line number Diff line number Diff line change 203203 @test @inferred (! issymmetric (g))
204204 end
205205
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+
206215 nx = 20
207216 ny = 21
208217 @testset " Cartesian Product / Crosspath: $g " for g in testlargegraphs (path_graph (ny))
You can’t perform that action at this time.
0 commit comments