Skip to content

Commit dda535c

Browse files
authored
add data-free methods for add_vertex! and add_edge!
1 parent f546d96 commit dda535c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/graphs.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ end
8888
add_vertex!(meta_graph, label, data)
8989
9090
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.
9192
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 incase the label already exists or vertex
94+
was not added.
9395
"""
9496
function Graphs.add_vertex!(meta_graph::MetaGraph, label, data)
9597
if haskey(meta_graph, label)
@@ -106,10 +108,15 @@ function Graphs.add_vertex!(meta_graph::MetaGraph, label, data)
106108
return added
107109
end
108110

111+
function Graphs.add_vertex!(meta_graph::MetaGraph{<:Any, <:Any, <:Any, Nothing}, label)
112+
Graphs.add_vertex!(meta_graph, label, nothing)
113+
end
114+
109115
"""
110116
add_edge!(meta_graph, label_1, label_2, data)
111117
112118
Add an edge `(label_1, label_2)` to MetaGraph `meta_graph` with metadata `data`.
119+
If the `EdgeData` type of `meta_graph` is `Nothing`, `data` can be omitted.
113120
114121
Return `true` if the edge has been added, `false` otherwise.
115122
"""
@@ -122,6 +129,12 @@ function Graphs.add_edge!(meta_graph::MetaGraph, label_1, label_2, data)
122129
return added
123130
end
124131

132+
function Graphs.add_edge!(meta_graph::MetaGraph{<:Any, <:Any, <:Any, <:Any, Nothing},
133+
label_1, label_2)
134+
Graphs.add_edge!(meta_graph, label_1, label_2, nothing)
135+
end
136+
137+
125138
## Remove vertex
126139

127140
function _rem_vertex!(meta_graph::MetaGraph, label, code)

0 commit comments

Comments
 (0)