Skip to content

Commit d881c5d

Browse files
committed
add wiki (fixed)
1 parent d1d1d40 commit d881c5d

13 files changed

Lines changed: 364 additions & 1 deletion

wiki

Lines changed: 0 additions & 1 deletion
This file was deleted.

wiki/Array1DTracer.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Array1DTracer** inherits **[Array2DTracer](Array2DTracer)**.
2+
3+
## Methods
4+
5+
| Method | Description |
6+
|--------|-------------|
7+
| **Array1DTracer**((String) name) | create Array1DTracer and set its name |
8+
| **attach**((ChartTracer) chartTracer)| automatically visualize array data to the bar chart |
9+
| **palette**((Object) {selected, notified, default})| set colors (e.g., `{selected: 'green', notified: '#FFA500', default: 'rgb(255,255,255)'}`) |
10+
| **_setData**((Number[]) data)| set one-dimensional array data to visualize |
11+
| **_notify**((Number) idx, (Number) v) | notify that the value of element _idx_ has been changed to _v_ |
12+
| **_denotify**((Number) idx) | stop notifying that the value of element _idx_ has been changed |
13+
| **_select**((Number) s, (Number) e) | select a range between elements _s_ and _e_ |
14+
| **_select**((Number) idx) | select element _idx_ |
15+
| **_deselect**((Number) s, (Number) e) | deselect a range between elements _s_ and _e_ |
16+
| **_deselect**((Number) idx) | deselect element _idx_ |
17+
| **_separate**((Number) idx) | put a divider between elements _idx_ and (_idx+1_) |
18+
| **_deseparate**((Number) idx) | remove a divider between elements _idx_ and (_idx+1_) |
19+
| **_clear**() | erase traces on the array |
20+
| **_wait**() | wait for a certain amount of time |
21+
22+
## Usage
23+
[Show examples](https://github.com/search?utf8=✓&q=Array1DTracer+repo%3Aparkjs814%2FAlgorithmVisualizer+path%3A%2Falgorithm&type=Code&ref=advsearch&l=&l=)

wiki/Array2DTracer.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
**Array2DTracer** inherits **[Tracer](Tracer)**.
2+
3+
## Methods
4+
5+
| Method | Description |
6+
|--------|-------------|
7+
| **Array2DTracer**((String) name)| create Array2DTracer and set its name |
8+
| **palette**((Object) {selected, notified, default})| set colors (e.g., `{selected: 'green', notified: '#FFA500', default: 'rgb(255,255,255)'}`) |
9+
| **_setData**((Number[][]) data)| set two-dimensional array data to visualize |
10+
| **_notify**((Number) x, (Number) y, (Number) v) | notify that the value of (x, y) has been changed to _v_ |
11+
| **_denotify**((Number) x, (Number) y) | stop notifying that the value of (x, y) has been changed |
12+
| **_select**((Number) sx, (Number) sy, (Number) ex, (Number) ey) | select a rectangle formed by (sx, sy) and (ex, ey) |
13+
| **_select**((Number) x, (Number) y) | select (x, y) |
14+
| **_selectRow**((Number) x, (Number) sy, (Number) ey) | equivalent to **_select**(x, sy, x, ey) |
15+
| **_selectCol**((Number) y, (Number) sx, (Number) ex) | equivalent to **_select**(sx, y, ex, y) |
16+
| **_deselect**((Number) sx, (Number) sy, (Number) ex, (Number) ey) | deselect a rectangle formed by (sx, sy) and (ex, ey) |
17+
| **_deselect**((Number) x, (Number) y) | deselect (x, y) |
18+
| **_deselectRow**((Number) x, (Number) sy, (Number) ey) | equivalent to **_deselect**(x, sy, x, ey) |
19+
| **_deselectCol**((Number) y, (Number) sx, (Number) ex) | equivalent to **_deselect**(sx, y, ex, y) |
20+
| **_separate**((Number) x, (Number) y) | put dividers between _x_-th and (_x+1_)-th rows and between _y_-th and (_y+1_)-th columns |
21+
| **_separateRow**((Number) x) | put a divider between _x_-th and (_x+1_)-th rows |
22+
| **_separateCol**((Number) y) | put a divider between _y_-th and (_y+1_)-th columns |
23+
| **_deseparate**((Number) x, (Number) y) | remove dividers between _x_-th and (_x+1_)-th rows and between _y_-th and (_y+1_)-th columns |
24+
| **_deseparateRow**((Number) x) | remove a divider between _x_-th and (_x+1_)-th rows |
25+
| **_deseparateCol**((Number) y) | remove a divider between _y_-th and (_y+1_)-th columns |
26+
| **_clear**() | erase traces on the array |
27+
| **_wait**() | wait for a certain amount of time |
28+
29+
## Child Modules
30+
31+
* [Array1DTracer](Array1DTracer)
32+
33+
## Usage
34+
[Show examples](https://github.com/search?utf8=✓&q=Array2DTracer+repo%3Aparkjs814%2FAlgorithmVisualizer+path%3A%2Falgorithm&type=Code&ref=advsearch&l=&l=)

wiki/ChartTracer.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
**ChartTracer** inherits **[Tracer](Tracer)**.
2+
3+
## Methods
4+
5+
| Method | Description |
6+
|--------|-------------|
7+
| **ChartTracer**((String) name)| create ChartTracer and set its name |
8+
| **palette**((Object) {selected, notified, default})| set colors (e.g., `{selected: 'green', notified: '#FFA500', default: 'rgb(255,255,255)'}`) |
9+
| **_setData**((Number[]) data)| set one-dimensional array data to visualize |
10+
| **_notify**((Number) idx, (Number) v) | notify that the value of element _idx_ has been changed to _v_ |
11+
| **_denotify**((Number) idx) | stop notifying that the value of element _idx_ has been changed |
12+
| **_select**((Number) s, (Number) e) | select a range between elements _s_ and _e_ |
13+
| **_select**((Number) idx) | select element _idx_ |
14+
| **_deselect**((Number) s, (Number) e) | deselect a range between elements _s_ and _e_ |
15+
| **_deselect**((Number) idx) | deselect element _idx_ |
16+
| **_clear**() | erase traces on the chart |
17+
| **_wait**() | wait for a certain amount of time |
18+
19+
## Usage
20+
[Show examples](https://github.com/search?utf8=✓&q=ChartTracer+repo%3Aparkjs814%2FAlgorithmVisualizer+path%3A%2Falgorithm&type=Code&ref=advsearch&l=&l=)

wiki/Contributing.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
**NOTE**: Check out [**Project Details**](Project-Details) before running it locally!
2+
3+
To add changes and improvements or resolve issues, these are the usual steps:
4+
5+
1. Fork the project on Github then clone it to your machine:
6+
7+
```bash
8+
git clone https://github.com/<your-username>/AlgorithmVisualizer # clone your forked repo
9+
cd AlgorithmVisualizer # navigate inside the created directory
10+
git submodule init # initialize wiki submodule
11+
git submodule update # setup wiki submodule updates
12+
```
13+
2. Your fork's remote repository should be named `origin` by default, so add the main repository as a remote as well and give it a name to distinguish it from your fork (something like `main` would work):
14+
15+
```bash
16+
git remote add main https://github.com/parkjs814/AlgorithmVisualizer
17+
```
18+
19+
3. Create a branch addressing the issue/improvement you'd like to tackle.
20+
21+
```bash
22+
git checkout -b my-problem-fixer-branch
23+
```
24+
25+
4. Make your changes and push to `my-problem-fixer-branch` on your repo
26+
27+
```bash
28+
# write some awesome code and then ...
29+
git add .
30+
git commit -m "Explain my awesome changes"
31+
git push origin my-problem-fixer-branch
32+
```
33+
34+
5. Next create a pull request from `my-problem-fixer-branch` branch on `origin` to `master` branch on `main`.
35+
36+
6. Once approved, just delete `my-problem-fixer-branch` both locally and remotely because it's not needed anymore.
37+
38+
7. Finally, checkout `master` locally, pull the approved changes from the `main` repo, and push them to your `origin` repo:
39+
40+
```bash
41+
git checkout master # checkout master locally
42+
git pull main master # pull new changes from main repository
43+
git push main master # push the changes to your fork
44+
```
45+
46+
That's it, everything should be in sync now.
47+
48+
If you run into problems, feel free to [ask us for help on gitter](https://gitter.im/parkjs814/AlgorithmVisualizer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
49+
50+
As mentioned, check out [**Project Details**](Project-Details) for more information on how to run the project.

wiki/DirectedGraphTracer.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**DirectedGraphTracer** inherits **[Tracer](Tracer)**.
2+
3+
## Methods
4+
5+
| Method | Description |
6+
|--------|-------------|
7+
| **DirectedGraphTracer**((String) name)| create DirectedGraphTracer and set its name |
8+
| **attach**((LogTracer) logTracer)| automatically print log when visiting or leaving nodes |
9+
| **palette**((Object) {visited, left, default})| set colors (e.g., `{visited: 'green', left: '#FFA500', default: 'rgb(255,255,255)'}`) |
10+
| **_setTreeData**((Number[][]) tree, (Number) root) | set tree data to visualize |
11+
| **_setData**((Number[][]) graph) | set graph data to visualize |
12+
| **_visit**((Number) target, (Number) source) | visit _target_ node from _source_ node |
13+
| **_leave**((Number) target, (Number) source) | leave _target_ node to _source_ node |
14+
| **_clear**() | erase traces on the graph |
15+
| **_wait**() | wait for a certain amount of time |
16+
17+
## Child Modules
18+
19+
* [UndirectedGraphTracer](UndirectedGraphTracer)
20+
* [WeightedDirectedGraphTracer](WeightedDirectedGraphTracer)
21+
22+
## Usage
23+
[Show examples](https://github.com/search?utf8=✓&q=DirectedGraphTracer+repo%3Aparkjs814%2FAlgorithmVisualizer+path%3A%2Falgorithm&type=Code&ref=advsearch&l=&l=)

wiki/Home.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Check out:
2+
- [**Contributing**](Contributing) for details on how to contribute to our project and
3+
- [**Project Details**](Project-Details) for details on how to build/run the project
4+
5+
## Hierarchy of `algorithm` Directory
6+
| Path | Description |
7+
|------|-------------|
8+
| [/algorithm/category.json](https://github.com/parkjs814/AlgorithmVisualizer/tree/gh-pages/algorithm/category.json) | This file contains the list of categories and their algorithms. |
9+
| [/algorithm/[category]/[algorithm]/desc.json](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/algorithm/graph_search/dfs/desc.json) | This file contains the description of the algorithm and the list of its examples. |
10+
| [/algorithm/[category]/[algorithm]/[example]/data.js](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/algorithm/graph_search/dfs/tree/data.js) | This file predefines data variables that will be shown in a visualizing module. |
11+
| [/algorithm/[category]/[algorithm]/[example]/code.js](https://github.com/parkjs814/AlgorithmVisualizer/blob/gh-pages/algorithm/graph_search/dfs/tree/code.js) | This file actually implements and visualizes the algorithm. |
12+
13+
## Visualizing Modules
14+
* [Tracer](Tracer)
15+
* [LogTracer](LogTracer)
16+
* [Array2DTracer](Array2DTracer)
17+
* [Array1DTracer](Array1DTracer)
18+
* [DirectedGraphTracer](DirectedGraphTracer)
19+
* [UndirectedGraphTracer](UndirectedGraphTracer)
20+
* [WeightedDirectedGraphTracer](WeightedDirectedGraphTracer)
21+
* [WeightedUndirectedGraphTracer](WeightedUndirectedGraphTracer)
22+
* [ChartTracer](ChartTracer)
23+
24+
## Creating Random Data
25+
| Function | Description |
26+
|----------|-------------|
27+
| **Integer.random**((Number) min, (Number) max) | Create a random integer inclusively between _min_ and _max_. |
28+
| **Array2D.random**((Number) N, (Number) M, (Number) min, (Number) max) | Create random _N_ * _M_ array data that elements have a random value between _min_ and _max_. |
29+
| **Array2D.randomSorted**((Number) N, (Number) M, (Number) min, (Number) max) | Basically same as `Array2D.random` but elements in each row are sorted in increasing order. |
30+
| **Array1D.random**((Number) N, (Number) min, (Number) max) | Create random one-dimensional array data of size _N_ that elements have a random value between _min_ and _max_. |
31+
| **Array1D.randomSorted**((Number) N, (Number) min, (Number) max) | Basically same as `Array1D.random` but elements are sorted in increasing order. |
32+
| **DirectedGraph.random**((Number) N, (Number) ratio) | Create random graph data containing _N_ nodes and having directed edges between nodes at the probability of _ratio_ (between 0 and 1). |
33+
| **UndirectedGraph.random**((Number) N, (Number) ratio) | Basically same as `DirectedGraph.random` but edges do not have direction. |
34+
| **WeightedDirectedGraph.random**((Number) N, (Number) ratio, (Number) min, (Number) max) | Basically same as `DirectedGraph.random` but edges have a random weight between _min_ and _max_. |
35+
| **WeightedUndirectedGraph.random**((Number) N, (Number) ratio) | Basically same as `WeightedDirectedGraph.random` but edges do not have direction. |

wiki/LogTracer.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
**LogTracer** inherits **[Tracer](Tracer)**.
2+
3+
## Methods
4+
5+
| Method | Description |
6+
|--------|-------------|
7+
| **LogTracer**((String) name)| create LogTracer and set its name |
8+
| **_print**(msg) | print `msg` |
9+
| **_setData**(args) | _inherited, but not used_ |
10+
| **_clear**() | erase all logs |
11+
| **_wait**() | wait for a certain amount of time |
12+
13+
## Usage
14+
[Show examples](https://github.com/search?utf8=✓&q=LogTracer+repo%3Aparkjs814%2FAlgorithmVisualizer+path%3A%2Falgorithm&type=Code&ref=advsearch&l=&l=)

wiki/Project-Details.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
## Build System
2+
3+
Our project uses [gulp](http://gulpjs.com/) to:
4+
5+
- combine all individual modules into a single file
6+
- transpile ES6 code to ES5 with [babel.js](http://babeljs.io/)
7+
- minimize JS and CSS code
8+
- generate source maps
9+
- add vendor prefixer to the css
10+
- provide a server with live-reload
11+
12+
## Installation
13+
14+
```bash
15+
# install gulp globally so you can run it from the command line
16+
npm install -g gulp-cli
17+
18+
# install all dependencies
19+
npm install
20+
21+
# run gulp to start the livereload server on http://localhost:8080
22+
gulp
23+
```
24+
25+
**NOTE**: For Node.js versions below 0.12, you need to install an ES6-style Promise Polyfill (in case you receive a "Promise is undefined" error). To run with Promise, use:
26+
27+
```bash
28+
npm install es6-promise
29+
```
30+
31+
Then add the following line at the top of your *gulpfile.babel.js*:
32+
33+
```javascript
34+
var Promise = require ('es6-promise').Promise;
35+
```
36+
Check out [stackoverflow](http://stackoverflow.com/questions/32490328/gulp-autoprefixer-throwing-referenceerror-promise-is-not-defined) for more details on this issue.
37+
38+
To check your Node.js version, use:
39+
40+
```bash
41+
node --version
42+
```
43+
44+
## Code Structure
45+
46+
*Note:* Although no linter is added as of yet, the code closely follows the conventions from [Airbnb's ECMAScript 6 Javascript style guide](https://github.com/airbnb/javascript)
47+
48+
### [js/index.js](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js)
49+
50+
The app entry point is [`js/index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js).
51+
It performs the initial application setup (loads the app when jQuery loads, loads the initial data from the server etc.)
52+
53+
### [js/app/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/app)
54+
55+
The main application object is [`js/app/index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/app/index.js), which holds the necessary global application state flags and application level methods.
56+
It is [extended once the app loads in `index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js#L39) with the contents of [`app/constructor`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/app/constructor.js) and [`app/cache`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/app/cache.js).
57+
This means that from here on now, any file that does `require(/* path to js/app */)` is getting that populated object since calls to `require` are cached.
58+
59+
### [js/dom/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/dom)
60+
61+
The `js/dom` directory holds all the code interacting with the DOM (go figure 😜).
62+
The code is split into:
63+
64+
- "static" methods that are used everywhere (such as adding algorithm info to the DOM) and,
65+
- setup code which is called within the `app/constructor`, after the DOM is ready, to initialize all the elements with their contents and listeners.
66+
67+
### [js/editor/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/editor)
68+
69+
The `js/editor` directory holds the code to create and execute code in the ace editor.
70+
71+
### [js/module/\*/\*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/module)
72+
73+
The `js/module` directory holds all the tracers and the random-data-creators.
74+
All the modules are exported together and then "required" inside the entry point [`js/index.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js) where they are [attached to the global `window` object](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/index.js#L42) so [`eval` can use them](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/editor/executor.js#L12) when executing code in the code editor.
75+
76+
### [js/server/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/server)
77+
78+
The `js/server` directory holds all the code to load data from the server and utilizes promises from [RSVP.js](https://github.com/tildeio/rsvp.js/).
79+
In [`js/server/ajax`](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/server/ajax) are some helper methods to make requesting from the server a little easier.
80+
The main method is [`js/server/ajax/request.js`](https://github.com/parkjs814/AlgorithmVisualizer/blob/master/js/server/ajax/request.js) that is used by all other methods to call `$.ajax` with certain options and set/reset the global `isLoading` flag for every request.
81+
82+
### [js/trace_manager/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/server/ajax)
83+
84+
The `js/tracer_manager` directory holds the manager of tracers, which controls all the present tracers simultaneously.
85+
86+
### [js/utils/*.js](https://github.com/parkjs814/AlgorithmVisualizer/tree/master/js/utils)
87+
88+
The `utils` directory holds a few helper methods that are used everywhere such as building the strings for algorithm and file directories.

wiki/Tracer.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
**Tracer** is inherited by any other tracer modules.
2+
3+
## Methods
4+
5+
| Method | Description |
6+
|--------|-------------|
7+
| **Tracer**((String) name)| create Tracer and set its name |
8+
| **_setData**(args) | set data to visualize |
9+
| **_clear**() | clear the tracer |
10+
| **_wait**() | wait for a certain amount of time |
11+
12+
## Child Modules
13+
14+
* [LogTracer](LogTracer)
15+
* [DirectedGraphTracer](DirectedGraphTracer)
16+
* [Array2DTracer](Array2DTracer)
17+
* [ChartTracer](ChartTracer)

0 commit comments

Comments
 (0)