@@ -67,7 +67,13 @@ function MetaGraph(
67
67
weight_function= edge_data -> 1.0 ,
68
68
default_weight= 1.0 ,
69
69
) where {Code,Label,VertexData,EdgeData}
70
- @assert nv (graph) == 0
70
+ if nv (graph) != 0
71
+ throw (
72
+ ArgumentError (
73
+ " For this MetaGraph constructor, the underlying graph should be empty."
74
+ ),
75
+ )
76
+ end
71
77
if Label <: Integer
72
78
@warn " Constructing a MetaGraph with integer labels is not advised."
73
79
end
@@ -148,19 +154,37 @@ function MetaGraph(
148
154
default_weight= 1.0 ,
149
155
) where {Code,Label,VertexData,EdgeData}
150
156
# Construct vertex data
151
- @assert length (vertices_description) == nv (graph)
157
+ if length (vertices_description) != nv (graph)
158
+ throw (
159
+ ArgumentError (
160
+ " For this MetaGraph constructor, the description of vertices should contain as many vertices as the underlying graph." ,
161
+ ),
162
+ )
163
+ end
152
164
vertex_labels = Dict {Code,Label} ()
153
165
vertex_properties = Dict {Label,Tuple{Code,VertexData}} ()
154
166
for (code, (label, data)) in enumerate (vertices_description)
155
167
vertex_labels[code] = label
156
168
vertex_properties[label] = (code, data)
157
169
end
158
170
# Construct edge data
159
- @assert length (edges_description) == ne (graph)
171
+ if length (edges_description) != ne (graph)
172
+ throw (
173
+ ArgumentError (
174
+ " For this MetaGraph constructor, the description of edges should contain as many edges as the underlying graph." ,
175
+ ),
176
+ )
177
+ end
160
178
for ((label_1, label_2), _) in edges_description
161
179
code_1 = vertex_properties[label_1][1 ]
162
180
code_2 = vertex_properties[label_2][1 ]
163
- @assert has_edge (graph, code_1, code_2)
181
+ if ! has_edge (graph, code_1, code_2)
182
+ throw (
183
+ ArgumentError (
184
+ " For this MetaGraph constructor, each edge in the edge description should exist in the underlying graph." ,
185
+ ),
186
+ )
187
+ end
164
188
end
165
189
edge_data = Dict {Tuple{Label,Label},EdgeData} ()
166
190
for ((label_1, label_2), data) in edges_description
0 commit comments