MCPcopy Index your code
hub / github.com/marijnh/Eloquent-JavaScript / gridGraph

Function gridGraph

code/chapter/22_fast.js:33–43  ·  view source on GitHub ↗
(size)

Source from the content-addressed store, hash-verified

31}
32
33function gridGraph(size) {
34 let grid = new Graph();
35 for (let y = 0; y < size; y++) {
36 for (let x = 0; x < size; x++) {
37 let id = grid.addNode();
38 if (x > 0) grid.addEdge(id, id - 1);
39 if (y > 0) grid.addEdge(id, id - size);
40 }
41 }
42 return grid;
43}
44
45var springLength = 20;
46var springStrength = 0.1;

Callers

nothing calls this directly

Calls 2

addNodeMethod · 0.95
addEdgeMethod · 0.95

Tested by

no test coverage detected