Skip to content

Implement stack data visualization #75

Description

@YotamAshman

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:

Image

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:

Image

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:

Image

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Data VisualizationsVisually displaying stacks, queues, and moreUIThings connected to the visual part of the projectenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions