Skip to content

Commit

Permalink
Update tutorial on adding edges (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
bin-wang authored Jul 18, 2024
1 parent d2062f3 commit d59401c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "MetaGraphsNext"
uuid = "fa8bd995-216d-47f1-8a91-f3b68fbeb377"
version = "0.7.0"
version = "0.7.1"

[deps]
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
Expand Down
3 changes: 2 additions & 1 deletion src/graphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ Add an edge `(label_1, label_2)` to MetaGraph `meta_graph` with metadata `data`.
If the `EdgeData` type of `meta_graph` is `Nothing`, `data` can be omitted.
Return `true` if the edge has been added, `false` otherwise.
If `(label_1, label_2)` already existed, its data is updated to `data` and `false` is returned nonetheless.
If one of the labels does not exist, nothing happens and `false` is returned (the label is not inserted).
If `(label_1, label_2)` already exists, its data is updated to `data` and `false` is returned nonetheless.
"""
function Graphs.add_edge!(meta_graph::MetaGraph, label_1, label_2, data)
if !haskey(meta_graph, label_1) || !haskey(meta_graph, label_2)
Expand Down
2 changes: 1 addition & 1 deletion test/tutorial/1_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ colors[:blue] = (0, 0, 255);

# ### Edges

# Use `setindex!` with two keys to add a new edge between the given labels and containing the given metadata. Beware that this time, nonexistent labels will throw an error.
# Use `setindex!` with two keys to add a new edge between the given labels and containing the given metadata. Beware that this time, an edge will only be added when both node labels already exist in the graph.

colors[:red, :green] = :yellow;
colors[:red, :blue] = :magenta;
Expand Down

0 comments on commit d59401c

Please sign in to comment.