88
88
add_vertex!(meta_graph, label, data)
89
89
90
90
Add a vertex to MetaGraph `meta_graph` with label `label` having metadata `data`.
91
+ If the `VertexData` type of `meta_graph` is `Nothing`, `data` can be omitted.
91
92
92
- Return true if the vertex has been added, false incase the label already exists or vertex was not added.
93
+ Return true if the vertex has been added, false in case the label already exists or vertex was not added.
93
94
"""
94
95
function Graphs. add_vertex! (meta_graph:: MetaGraph , label, data)
95
96
if haskey (meta_graph, label)
96
97
return false
97
98
end
98
- added = add_vertex! (meta_graph. graph)
99
+ nvnum = nv (meta_graph. graph)
100
+ add_vertex! (meta_graph. graph)
101
+ added = nvnum + 1 == nv (meta_graph. graph)
99
102
if added
100
103
code = nv (meta_graph)
101
104
meta_graph. vertex_labels[code] = label
@@ -104,10 +107,15 @@ function Graphs.add_vertex!(meta_graph::MetaGraph, label, data)
104
107
return added
105
108
end
106
109
110
+ function Graphs. add_vertex! (meta_graph:: MetaGraph{<:Any,<:Any,<:Any,Nothing} , label)
111
+ return Graphs. add_vertex! (meta_graph, label, nothing )
112
+ end
113
+
107
114
"""
108
115
add_edge!(meta_graph, label_1, label_2, data)
109
116
110
117
Add an edge `(label_1, label_2)` to MetaGraph `meta_graph` with metadata `data`.
118
+ If the `EdgeData` type of `meta_graph` is `Nothing`, `data` can be omitted.
111
119
112
120
Return `true` if the edge has been added, `false` otherwise.
113
121
"""
@@ -120,6 +128,12 @@ function Graphs.add_edge!(meta_graph::MetaGraph, label_1, label_2, data)
120
128
return added
121
129
end
122
130
131
+ function Graphs. add_edge! (
132
+ meta_graph:: MetaGraph{<:Any,<:Any,<:Any,<:Any,Nothing} , label_1, label_2
133
+ )
134
+ return Graphs. add_edge! (meta_graph, label_1, label_2, nothing )
135
+ end
136
+
123
137
# # Remove vertex
124
138
125
139
function _rem_vertex! (meta_graph:: MetaGraph , label, code)
0 commit comments