-
Notifications
You must be signed in to change notification settings - Fork 62
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
Edgelabels attached to the wrong edges #192
Comments
Two additional observations:
|
Hi @colbec, Your issue is that your GraphPlot.jl iterates through using Graphs, SimpleWeightedGraphs, GraphPlot
using Random, Compose, Colors, Combinatorics
using Graphs, SimpleWeightedGraphs, GraphPlot
import Cairo, Fontconfig
function thetest()
num_v = 6
num_e = 4
G = SimpleWeightedGraph()
add_vertices!(G, num_v)
labels = collect(1:num_v)
nodecolors = rand(RGB{Float64},num_v)
edgecolors = colorant"lightgreen"
edgecombs = sort!(shuffle!(collect(combinations(1:num_v,2)))[1:num_e])
# edgeweights = []
for i in 1:num_e
wt = round(max(rand(),0.1),digits=2)
(x,y) = edgecombs[i]
add_edge!(G, x, y, wt)
println("$x, $y, $wt")
# push!(edgeweights,wt)
end
draw(
PNG("thetest.png",20cm,20cm),
gplot(G,nodelabel=labels,
layout=stressmajorize_layout,
nodefillc=nodecolors,
edgelabel=[G.weights[src(e),dst(e)] for e in edges(G)],#edgeweights,
edgestrokec=edgecolors
)
)
return G
end |
Indeed this solves my issue. Thanks. |
With Julia 1.8.3 Official release on openSUSE Leap 15.4 and Gnome:
With the following Julia code (uploaded as txt) I attempt to create a graph with 6 nodes and 4 edges. I assign random real values as weights to the edges. The adjacency matrix is created correctly but the attempt to use the edge weights as edge labels is only correct about 50% of the time. The weights are always correct, but as labels they are frequently attached to the wrong edges in the plot.
The last run produced the attached image and this output:
I believe this may be an issue, but also my coding may not be appropriate. I'm working on it.
edgetest.jl.txt
The text was updated successfully, but these errors were encountered: