Skip to content

Commit

Permalink
added removeedge! for Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
titaschanda committed Mar 3, 2024
1 parent 2cfafed commit 60fab63
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/base/graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,25 @@ end

#################################################################################

"""
function removeedge!(graph::Graph{T}, node1::T, node2::T) where T
Removes the edge between `node1` and `node2`. If `node1` or `node2` are not present in
the `Graph`, throws an error. If the edge does not exist, nothing is changed.
"""
function removeedge!(graph::Graph{T}, node1::T, node2::T)::Nothing where T
if !hasnode(graph, node1) || !hasnode(graph, node2)
error("`removeedge!()`: `node1=$node1` and/or `node2=$node2` do not exist in the graph !!")
end

delete!(graph[node1], node2)
delete!(graph[node2], node1)

return nothing
end

#################################################################################

"""
function isneighbor(graph::Graph{T}, node1::T, node2::T)::Bool where T
Expand Down
2 changes: 2 additions & 0 deletions src/export.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export
hasnode,
addnode!,
addedge!,
removeedge!,
isneighbor,
bfs,
nodes_from_bfs,
Expand Down Expand Up @@ -172,6 +173,7 @@ export
# ttn/helper_internal_funcs.jl

# ttn/ttn_generators.jl
distribute_site_positions,
default_graph_sitenodes,
randomTTN,
default_randomTTN,
Expand Down

0 comments on commit 60fab63

Please sign in to comment.