Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tutorial on adding edges #79

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading