Current behavior
While some algorithms use data structures such as stacks, queues and so on, there is no element in the app visually describing their purpose.
Desired behavior
A stack visualization needs to be intuitive and clear.
A simple rectangle with its top removed can be enough:
When elements go inside the stack, they should appear at the lowest position available.
For example, if vertex 7 goes in the stack, I think it should look something like:
Visually, it would be best if elements going in/out could be somewhat tweened, with a simple animation showing them perhaps fading in and moving down + moving out and fading off.
To many elements
The stack should only actually display an arbitrary $N$ elements ($N$ is up to the implementer).
If the amount of elements surpasses that, the elements should be abstracted in some way.
For example:
Approach
This element is a scene of its own.
A stack might be used by many algorithms, and so it should be somewhat generic.
How generic should the implementation be
I don't think it's possible to make this super-generic in such a way that the same implementation will work for every algorithm.
Each algorithm might need different visual representations of the elements inside the stack.
Because of this, I think the stack implemented here should be somewhat generic.
It should expose a simple API such as:
func add_to_stack(element) -> void
func pop_stack() -> void
Notice that the pop function returns NOTHING. This is because this stack is a VISUAL representation only. The actual algorithm logic will have it's own logic-only stack it will use for actual logic operations.
These functions will also trigger the relevant visual effects to display the data.
If some algorithm requires more control of the elements shown inside, it will have to create a duplicate stack scene of this implementation, and change it to its needs (e.g., DfsStack).
Current behavior
While some algorithms use data structures such as stacks, queues and so on, there is no element in the app visually describing their purpose.
Desired behavior
A stack visualization needs to be intuitive and clear.
A simple rectangle with its top removed can be enough:
When elements go inside the stack, they should appear at the lowest position available.
For example, if vertex 7 goes in the stack, I think it should look something like:
Visually, it would be best if elements going in/out could be somewhat tweened, with a simple animation showing them perhaps fading in and moving down + moving out and fading off.
To many elements
The stack should only actually display an arbitrary$N$ elements ($N$ is up to the implementer).
If the amount of elements surpasses that, the elements should be abstracted in some way.
For example:
Approach
This element is a scene of its own.
A stack might be used by many algorithms, and so it should be somewhat generic.
How generic should the implementation be
I don't think it's possible to make this super-generic in such a way that the same implementation will work for every algorithm.
Each algorithm might need different visual representations of the elements inside the stack.
Because of this, I think the stack implemented here should be somewhat generic.
It should expose a simple API such as:
These functions will also trigger the relevant visual effects to display the data.
If some algorithm requires more control of the elements shown inside, it will have to create a duplicate stack scene of this implementation, and change it to its needs (e.g.,
DfsStack).