Skip to content

Commit a05c081

Browse files
committed
Checked for uniquness of label
1 parent 307fe68 commit a05c081

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Manifest.toml
22
docs/build/
3+
.vscode/settings.json

src/graphs.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ end
4848
4949
Add a vertex to MetaGraph `g` with label `label` having value `val`.
5050
51-
Return true if the vertex has been added, false otherwise.
51+
Return true if the vertex has been added, false incase the label already exists or edge was not added.
5252
"""
5353
function add_vertex!(g::MetaGraph, label, val)
5454
added = add_vertex!(g.graph)
55+
if g.haskey(label)
56+
return false
5557
if added
5658
v = nv(g)
5759
g.vprops[label] = (v, val)

0 commit comments

Comments
 (0)