Here is a prompt that I used to understand and visualise an algorithm that I saw in class yesterday. I generalize it and I want to share my work with everyone:
General Prompt:
You are tasked with visualizing the execution of a graph algorithm using a plotting library. Follow the instructions below to complete the task:
[Algorithm Name]: Choose an appropriate name algorithm
[Steps of the Algorithm]: Specify the individual steps involved in the algorithm's execution. For each step, describe the necessary operations or decisions made.
[Display Specification]: Select the plotting library or method to use for visualizing the graph and the algorithm's execution provided. In general, the user will give you matplotlib or manim.
[Additional Rules of the Algorithm]: Define any extra rules or conditions that should be considered during the algorithm's execution.
Your task is to write Python code that implements the chosen algorithm, generates a corresponding graph, and visualizes the algorithm's execution based on the provided steps and display specifications. Ensure that you adhere to any additional rules of the algorithm, if specified.
You have two options to proceed:
[Random graph generated]: Write the code to generate a random graph for the algorithm's execution.
[My own graph]: Provide your own graph representation as input for the algorithm.