- No longer check the boundary of index of elements in the
*_advancemethods, please ensure the range valid by yourself. - Renamed the
VanillaFindsettoFindset. - Refined the methods, see the
IFindset,IHeuristicFindset,IEnhancedFindsetinterfaces for more details.
- Added new
Deque(implemented with linked list). - Refined the methods, see the
IQueue,ICircularQueue,IDeque,IPriorityQueueinterfaces for more details.
- Removed the
UnsafeTrie, please the useTriedirectly. - No longer check the boundary of index of elements in the
*_advancemethods, please ensure the range valid by yourself. - Refined the methods, removed the UnsafeTrie, see the
ITrieinterfaces for more details.
- This package has been removed, some graph related types moved to @algorithm.ts/graph.types
No breaking changes.
-
Constructor: Only the
INFprops reserved, thefrom,dist,inq,inqTimesare not supported anymore. -
Get shortest path: no builtin
getShortestPathToanymore, call thegetShortestPathfrom the@algorithm.ts/graphinstead. -
bellmanFordreturns a structured result instead of a boolean value.export type IBellmanFordResult<C extends number | bigint> = | { // There is at least one negative cycle in the graph, so the shortest path is not existed. hasNegativeCycle: true } | { hasNegativeCycle: false /** * A big number, representing the unreachable cost. */ INF: C /** * Source point */ source: number /** * Record the shortest path parent source point to the specified point. * For example: bestFrom[x] represents the previous position of x in the shortest path * parent the source point to x. */ bestFrom: ReadonlyArray<number> /** * An array recording the shortest distance to the source point. */ dist: ReadonlyArray<C> }
-
createBinaryIndexTree1is removed, useSingleUpdateIntervalQueryinstead. -
createBinaryIndexTree2is removed, useSingleUpdateIntervalQueryinstead. -
No builtin modulo binary index tree, perform the modulus operations through customized
addmethod:import { SingleUpdateIntervalQuery } from '@algorithm.ts/binary-index-tree' const MOD = 1e9 + 7 const bit = SingleUpdateIntervalQuery<number>({ operator: { ZERO: 0, add: (x, y) => ((x + y) % MOD + MOD) % MOD, }, })
- Renamed to
@algorithm.ts/bipartite-matching. - Use
new HungarianDfs()(ornew HungarianBfs()) instead ofcreateBipartiteGraphMatching
- Renamed to
@algorithm.ts/calculator. - Use
calculator.calculate(<expression>)instead ofcalculate(<expression>).
This package is removed, use @algorithm.ts/queue instead.
- Use
.sizeinstead of.size(). .end()is renamed to.back()..get()is removed..set()is removed..isValidIndex()is removed..isEmpty()is removed, use.size > 0instead.
-
dijkstrareturns a structured result instead of a number array.export interface IDijkstraResult<C extends number | bigint> { /** * A big number, representing the unreachable cost. */ INF: C /** * Source point */ source: number /** * Record the shortest path parent source point to the specified point. * For example: bestFrom[x] represents the previous position of x in the shortest path * parent the source point to x. */ bestFrom: ReadonlyArray<number> /** * An array recording the shortest distance to the source point. */ dist: ReadonlyArray<C> }
Removed, use @algorithm.ts/dijkstra instead.
import { dijkstraBigint } from '@algorithm.ts/dijkstra'-
Use
new Dinic()instead ofcreateDinic() -
.maxFlow()is renamed to.maxflow() -
.solve()is removed, if you want to access the residual network after run the.maxflow(), you can try to extend theDinicand export a method such asgetSnapshot().class CustomDinic extends Dinic { public getSnapshot() { return { N: this._N, source: this._source, sink: this._sink, G: this.G, edges: this._edges, edgesTot: this._edgesTot, dist: this._dist } } }
- Use
new DancingLinkX({ MAX_N: <number> })instead ofcreateDLX(<number>)
- Use
new Findset()instead ofcreateFindset(). - Use
new HeuristicFindset()instead ofcreateHeuristicFindset(). - Use
new EnhancedFindset()instead ofcreateEnhancedFindset(). .size(<number>)is renamed to.count(<number>)..resetNode(<number>)is removed.
No breaking changes.
No breaking changes.
- The graph related types is moved to
@algorithm.ts/types.
buildEncodingTableis renamed totoEncodingTable.buildHuffmanTreeis renamed tofromEncodingTable.createHuffmanTreeis renamed tofromText.
-
Use
new Isap()instead ofcreateIsap() -
.maxFlow()is renamed to.maxflow() -
.solve()is removed, if you want to access the residual network after run the.maxflow(), you can try to extend theIsapand export a method such asgetSnapshot().class CustomIsap extends Isap { public getSnapshot() { return { N: this._N, source: this._source, sink: this._sink, G: this.G, edges: this._edges, edgesTot: this._edgesTot, dist: this._dist } } }
- Renamed to
@algorithm.ts/shuffle.
No breaking changes.
This package is removed, use @algorithm.ts/binary-search instead.
import { lowerBound } from '@algorithm.ts/binary-search'- Return
number[]instead ofUint32Array.
-
Use
new Mcmf()instead ofcreateMcmf() -
.minCostMaxFlow()return an object instead of tuple. -
.solve()is removed, if you want to access the residual network after run the.maxflow(), you can try to extend theMcmfand export a method such asgetSnapshot().class CustomMcmf extends Mcmf { public getSnapshot() { return { N: this._N, source: this._source, sink: this._sink, G: this.G, edges: this._edges, edgesTot: this._edgesTot, dist: this._dist } } }
This package is removed, use @algorithm.ts/queue instead.
- !!! Priority queue is a Min-Heap now (previous version is a Max-Heap).
- Use
.sizeinstead of.size(). .top()is renamed to.front()..replaceTop(newElement)is removed, useQ.dequeue(newElement)instead..isEmpty()is removed, use.size > 0instead..collect()is removed, useArray.from(Q)instead.
No breaking changes.
- Renamed to
@algorithm.ts/prime.
-
This package is removed, use
@algorithm.ts/primeinstead.import { sieveTotient } from '@algorithm.ts/prime'
- Use
new SlidingWindow(options)instead ofcreateSlidingWindow(cmp). max()is removed, usemin()instead. The sliding-window is maintain the minimum value index now (the previous version will maintain the maximum value in the window).- Rename
moveForwardtoforwardRightBoundary. - Support to move the left boundary of the sliding-window through the new method
forwardLeftBoundary. init()is renamed toreset(), and the parameters is changed to object style.
-
Use one-dimension array to record a sudoku puzzle / solution data. (Previous version were using two-dimension array).
Once you still want to get a two-dimension array, here is an example shows that.
import { toMatrixStyleBoardData } from '@algorithm.ts/sudoku' // Convert the two-dimensional array to one-dimensional array. const puzzle = oldStylePuzzle.flat() solver.solve(puzzle, solution) // Convert the one-dimensional array to two-dimensional array. const oldStyleSolution = toMatrixStyleBoardData(solution)
-
createSudokuBoard()is renamed tocreateSudokuBoardData(). -
fillSudokuBoard()is renamed tofillSudokuBoardData(). -
copySudokuBoard()is renamed tocopySudokuBoardData(). -
checkSudokuSolutionis renamed tocheckSudokuSolution.
.insert()is renamed to.set()..math()is renamed to.get()..hasPrefixMatchedis renamed to.hasPrefix()..init()is removed, use.clear()to initialize trie.
-
This package is removed, use
@algorithm.ts/binary-searchinstead.import { upperBound } from '@algorithm.ts/binary-search'