You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
I am implementing a function merges two vertices of a MetaDiGraph and retains the current edges
using LightGraphs, MetaGraphs
function joinedge!(graph, v1, v2)
add_vertex!(graph)
v = nv(graph)
for i in vcat(outneighbors(graph,v1),outneighbors(graph,v2))
add_edge!(graph,v,i)
end
for i in vcat(inneighbors(graph,v1),inneighbors(graph,v2))
add_edge!(graph,i,v)
end
rem_vertex!(graph, max(v1,v2))
rem_vertex!(graph, min(v1,v2))
graph
end
I am guessing that this is related to #21 because when I change my code to
function joinedge!(graph, v1, v2)
add_vertex!(graph)
v = nv(graph)
for i in vcat(outneighbors(graph,v1),outneighbors(graph,v2))
if !(i in (v1,v2))
add_edge!(graph,v,i)
end
end
for i in vcat(inneighbors(graph,v1),inneighbors(graph,v2))
if !(i in (v1,v2))
add_edge!(graph,i,v)
end
end
rem_vertex!(graph, max(v1,v2))
rem_vertex!(graph, min(v1,v2))
graph
end
it works. The difference here is that I am no longer adding edges to the joined vertex which produce self-loops.
The text was updated successfully, but these errors were encountered:
I am implementing a function merges two vertices of a MetaDiGraph and retains the current edges
When I run this on for example a wheelgraph
I get the following error
ERROR: LoadError: KeyError: key 3 not found
I am guessing that this is related to #21 because when I change my code to
it works. The difference here is that I am no longer adding edges to the joined vertex which produce self-loops.
The text was updated successfully, but these errors were encountered: