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

TreePlot & linked lists #193

Open
vbgl opened this issue Dec 4, 2023 · 0 comments
Open

TreePlot & linked lists #193

vbgl opened this issue Dec 4, 2023 · 0 comments

Comments

@vbgl
Copy link

vbgl commented Dec 4, 2023

I’m trying to plot list-like tree structures using TreePlot and get various errors. Here is a minimal example.

using GraphRecipes, AbstractTrees, Plots

abstract type L end
struct E <: L end
struct N <: L n :: L end

Base.isempty(::E) = true

AbstractTrees.children(l :: N) = [ l.n ]
AbstractTrees.printnode(io::IO, ::E) = print(io, "E")
AbstractTrees.printnode(io::IO, ::N) = print(io, "N")

plot(TreePlot(E()))
plot(TreePlot(N(E())))
plot(TreePlot(N(N(E()))))

The first plot crashes with

MethodError: reducing over an empty collection is not allowed; consider supplying init to the reducer

The second with

DimensionMismatch: new dimensions (4, 0) must be consistent with array size 2

The last one with

DivideError: integer division error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant