The graphplot function does not allow plotting graphs with nodes that have unconnected edges. To manage this, "ghost" nodes with zero size are internally created at the edges where there are no direct connections. While these "ghost" nodes are invisible in the plot, they introduce inconsistencies when using the node_attr keyword arguments such as node_size, node_color, etc., in the plot function.
Specifically, when a user passes a Vector for some node_attr, the function also expects values for these invisible "ghost" nodes, which I believe is counter-intuitive to the user. Users would naturally expect to specify attributes only for the "real" nodes, and have the "ghost" nodes' attributes be handled internally by the plot function. Requiring users to pass in extra attribute values for "ghost" nodes complicates the interface and can lead to errors.
Example
julia> using Makie; using CairoMakie; using Tenet
julia> fig = Figure()
julia> t_lm = Tensor(rand(2, 2), (:l, :m))
2×2 Tensor{Float64, 2, Matrix{Float64}}: ...
julia> t_ilm = Tensor(rand(2, 2, 2), (:i, :l, :m))
2×2×2 Tensor{Float64, 3, Array{Float64, 3}}: ...
julia> tn = TensorNetwork([t_ilm, t_lm])
TensorNetwork{Arbitrary, NamedTuple{(), Tuple{}}}(#tensors=2, #inds=3)
julia> plot(tn; node_color=[:red, :green])
Error showing value of type Makie.FigureAxisPlot:
ERROR: All non scalars need same length, Found lengths for each argument: (3, 2, 3, 1, 1, 3, 3, 1), (Vector{Point{2, Float32}}, Vector{ColorTypes.RGBA{Float32}}, Vector{Real}, ColorTypes.RGBA{Float32}, Float32, Vector{BezierPath}, Vector{Vec{2, Float32}}, Quaternionf)
Stacktrace:
...
Summary
The
graphplot
function does not allow plotting graphs with nodes that have unconnected edges. To manage this, "ghost" nodes with zero size are internally created at the edges where there are no direct connections. While these "ghost" nodes are invisible in the plot, they introduce inconsistencies when using thenode_attr
keyword arguments such asnode_size
,node_color
, etc., in theplot
function.Specifically, when a user passes a
Vector
for somenode_attr,
the function also expects values for these invisible "ghost" nodes, which I believe is counter-intuitive to the user. Users would naturally expect to specify attributes only for the "real" nodes, and have the "ghost" nodes' attributes be handled internally by theplot
function. Requiring users to pass in extra attribute values for "ghost" nodes complicates the interface and can lead to errors.Example