Skip to content
Madita Antonia Plogsties edited this page Mar 31, 2025 · 7 revisions

Save and upload of graph from a file (files.ts)

The saveFile and saveTex functions are used to download the graph in json and tikz format and the readFile function is used for the upload of the graph. See more here.

Interfaces for the rust graphs and checking graph validity (graphs.ts)

This file includes the interfaces for BasicGraphNodeRS, BasicGraphLinkRS, GraphRS and GraphTS. These are extended for the specific algorithms in their respective config.ts file.

The checkGraphForValidity function checks whether a JSON graph, normally an uploaded one, is of a correct format and has values within the allowed ranges. The graph weights are restricted by JavaScripts Number.isSafeInteger().

Information about the algorithms that exist (available-algorithms.ts)

This file contains all information of an algorithms that is needed for the application. The file consists of an interface IAlgorithmInformation which defines the properties of an algorithm and an array AvailableAlgorithm which contains all the algorithms that are available in the app.

This structure, among other things, adds an abstraction between the react components and the algorithm specific properties contained in the /src/algorithms folder, leading to a more maintainable codebase.

To add a new algorithm, the following properties need to be defined:

  • name: The name of the algorithm
  • description: A brief description of the algorithm which is displayed at the graph page
  • category: The category of the algorithm which is displayed at the home page
  • useAlgorithmStore: The store which holds the state of the algorithm
  • getRandomGraph: A function that generates a random graph based on the algorithm

Additional functionality is hold in the features property. Example features are the different available training pages, since not every algorithm may have all training modes available and they can also differ in the way they are implemented for each algorithm.

Different graph generator functions (graphGenerator.ts)

Functions to generate different graphs independent from algorithm. There are functions to generate random graphs, random trees, complete graphs, and graphs that are most likely not connected.


Didn't find what you were looking for?

There are several other simple utility functions, such as string capitalization and finding the smallest unique new ID from an array of IDs. If you need a small, reusable function, first check if one already exists. If not, create one and add it in the utils folder.

Clone this wiki locally