@@ -6,69 +6,66 @@ import Test: @testset, @test
6
6
7
7
doctest (MetaGraphs)
8
8
9
- test = meta_graph (DiGraph (), AtVertex = Symbol, AtEdge = Symbol)
10
- rock = push! (test , :rock )
11
- scissors = push! (test , :scissors )
12
- paper = push! (test , :paper )
9
+ rock_paper_scissors = meta_graph (DiGraph (), AtVertex = Symbol, AtEdge = Symbol)
10
+ rock = push! (rock_paper_scissors , :rock )
11
+ paper = push! (rock_paper_scissors , :paper )
12
+ scissors = push! (rock_paper_scissors , :scissors )
13
13
14
- test [Edge (rock, scissors)] = :rock_beats_scissors
15
- test [Edge (scissors, paper)] = :scissors_beats_paper
16
- test [Edge (paper, rock)] = :paper_beats_rock
14
+ rock_paper_scissors [Edge (rock, scissors)] = :rock_beats_scissors
15
+ rock_paper_scissors [Edge (scissors, paper)] = :scissors_beats_paper
16
+ rock_paper_scissors [Edge (paper, rock)] = :paper_beats_rock
17
17
18
- test2 = induced_subgraph (test , [1 , 2 ])
18
+ rock_paper = induced_subgraph (rock_paper_scissors , [1 , 2 ])
19
19
20
20
@testset " Miscellaneous" begin
21
- @test haskey (reverse (test), Edge (scissors, rock))
22
- @test nv (test2) == 2
23
- @test ne (test2) == 1
24
- @test haskey (test2, Edge (rock, scissors))
21
+ @test haskey (reverse (rock_paper_scissors), Edge (scissors, rock))
22
+ @test nv (rock_paper) == 2
23
+ @test ne (rock_paper) == 1
24
+ @test haskey (rock_paper, Edge (paper, rock))
25
+ @test SimpleGraph (meta_graph (Graph ())) isa SimpleGraph
25
26
end
26
27
28
+ rock_paper_scissors_copy = copy (rock_paper_scissors)
29
+
27
30
@testset " Inheritance" begin
28
- @test copy (test) == test
29
- @test nv (zero (test )) == 0
30
- @test ne (test ) == 3
31
- @test fadj (test , rock) == [scissors]
32
- @test badj (test , rock) == [paper]
33
- @test typeof (rock) == eltype (test )
34
- @test edgetype (test ) == Edge{Int}
35
- @test vertices (test ) == Base. OneTo (3 )
36
- @test weight_type (test ) == Float64
37
- @test has_edge (test , Edge (rock, scissors))
38
- @test has_vertex (test , rock)
39
- @test issubset (test2, test )
40
- @test SimpleDiGraph (test ) isa SimpleDiGraph
31
+ @test rock_paper_scissors_copy == rock_paper_scissors
32
+ @test nv (zero (rock_paper_scissors )) == 0
33
+ @test ne (rock_paper_scissors ) == 3
34
+ @test fadj (rock_paper_scissors , rock) == [scissors]
35
+ @test badj (rock_paper_scissors , rock) == [paper]
36
+ @test typeof (rock) == eltype (rock_paper_scissors )
37
+ @test edgetype (rock_paper_scissors ) == Edge{Int}
38
+ @test vertices (rock_paper_scissors ) == Base. OneTo (3 )
39
+ @test weight_type (rock_paper_scissors ) == Float64
40
+ @test has_edge (rock_paper_scissors , Edge (rock, scissors))
41
+ @test has_vertex (rock_paper_scissors , rock)
42
+ @test issubset (rock_paper, rock_paper_scissors )
43
+ @test SimpleDiGraph (rock_paper_scissors ) isa SimpleDiGraph
41
44
end
42
45
43
- test2 = copy (test)
44
-
45
46
@testset " Double check deletion" begin
46
- delete! (test , rock)
47
- @test ne (test ) == 1
48
- @test filter_edges (test , isequal (:scissors_beats_paper )) == [Edge (2 , 1 )]
49
- delete! (test2, scissors )
50
- @test ne (test2 ) == 1
51
- @test filter_edges (test2 , isequal (:paper_beats_rock )) == [Edge (2 , 1 )]
52
- rem_edge! (test , Edge (2 , 1 ))
53
- @test ne (test ) == 0
54
- rem_vertex! (test , 2 )
55
- @test nv (test ) == 1
47
+ delete! (rock_paper_scissors , rock)
48
+ @test ne (rock_paper_scissors ) == 1
49
+ @test filter_edges (rock_paper_scissors , isequal (:scissors_beats_paper )) == [Edge (1 , 2 )]
50
+ delete! (rock_paper_scissors_copy, paper )
51
+ @test ne (rock_paper_scissors_copy ) == 1
52
+ @test filter_edges (rock_paper_scissors_copy , isequal (:rock_beats_scissors )) == [Edge (1 , 2 )]
53
+ rem_edge! (rock_paper_scissors , Edge (1 , 2 ))
54
+ @test ne (rock_paper_scissors ) == 0
55
+ rem_vertex! (rock_paper_scissors , 2 )
56
+ @test nv (rock_paper_scissors ) == 1
56
57
end
57
58
58
- test = meta_graph (DiGraph (), AtVertex = Symbol, AtEdge = Float64, weight_function = identity)
59
- rock = push! (test, :rock )
60
- scissors = push! (test, :scissors )
61
- paper = push! (test, :paper )
62
-
63
- test[Edge (rock, scissors)] = 1
64
- test[Edge (scissors, paper)] = 2
65
- w = weights (test)
59
+ weighted_graph = meta_graph (DiGraph (), AtEdge = Float64, weight_function = identity)
60
+ push! (weighted_graph, nothing )
61
+ push! (weighted_graph, nothing )
62
+ push! (weighted_graph, nothing )
63
+ weighted_graph[Edge (1 , 2 )] = 1
64
+ weighted_graph[Edge (2 , 3 )] = 2
65
+ graph_weights = weights (weighted_graph)
66
66
67
67
@testset " Weights" begin
68
- @test string (w ) == " metaweights"
69
- @test w [rock, paper] == 1.0
70
- @test size (w ) == (3 , 3 )
68
+ @test string (graph_weights ) == " metaweights"
69
+ @test graph_weights [rock, paper] == 1.0
70
+ @test size (graph_weights ) == (3 , 3 )
71
71
end
72
-
73
- test = meta_graph (Graph ())
74
- @test SimpleGraph (test) isa SimpleGraph
0 commit comments