Quick Start

Setting up and running the demo

The code was built and delivered as a Visual Studio 2015 solution. It comes with a demo to illustrate basic capabilities of the library and tool. If you are already familiar with Visual Studio, you can go directly to step 4 to run the demo. If you do not have Visual Studio, download the free Visual Studio Community Edition and follow the instruction to install the software. Once the installation is complete:

  1. Clone or download the Algs4Net solution and change to the directory where the Algs4Net.sln file is.
  2. Use Visual Studio to open Algs4net.sln. After the solution is loaded, within the Solution Explorer window, there are three projects:
    1. Algs4Net is the core library of the solution
    2. Algs4NetTests contains sample unit tests for selected classes from Algs4Net
    3. AlgsCmd is the command-line tool to call MainTest’s methods of Algs4Net classes.
  3. In Solution Explorer, make sure that AlgsCmd is the StartUp project by right clicking the project and select the "Set as StartUp project" option in the pop-up menu. Then AlgsCmd should be in bold, meaning that it is now the StartUp project.
  4. Also, right click the project and select the "Properties" option to open the project properties in the main Visual Studio window:
    1. Examine the properties to suite your needs. Particularly note the working directory of the program. It is where you may later put data files as needed.
    2. Note that in the DebugStart Options section, there is a text box for command line arguments. Enter Animation to run the demo.
  5. In Visual Studio, select BuildBuild Solution or press Ctrl-Shift-B to build all the projects.
  6. After the build is complete, select DebugStart Debugging (or Start Without Debugging) to run the program.
  7. A window should come up and ready to run the demo. Switch to the new window, click the Start button to start the animation, Stop to stop it. Optionally, select the File menu to save the display in a file.
  8. Exit the demo window. Even though the demo has illustrated the library's basic drawing capabilities, most of the times you will be using algscmd with the console for your algorithms. As you may already know, the console can be accessed from the IDE or command line.
  9. To run the demo from a command line, open the command line window and change directory to [path-to-algs4net]\Algs4Net\AlgsCmd\bin\Debug (or Release) and enter the command: algscmd Animation. The demo window should pop up from the command line window.

How to add new classes to Algs4Net

You may have already figured out how. This instruction is provided for completeness:

  1. Add a new class to the Algs4Net project from Visual Studio.
  2. Write the core code for the class.
  3. Add the public static void MainTest(string[] args) method to the class.
  4. Write the test code for the method.
  5. The MainTest method is your demo test to run with algscmd. Know which arguments you may need for the test and parse them from the args array, starting at index 0 as if you would from a console program's Main entry.
  6. When you are ready to run the test, open the AlgsCmd project properties and enter in the text box the name of your class followed by your arguments in parsing order.
  7. If you want to add drawing capabilities, follow the example in the Animation class.

What’s next

After the setup, follow these tips to test and develop your own algorithms using the library:

Since the library is intended use with the Algorithms, 4th Edition textbook, the text’s web site is the main resource for everything else. There is much to improve to the library and you are welcome to change it to suite your needs. Also, please do not hesitate to report issues as we are committed to provide follow-on support for the library and will welcome any feedback.