Skip to content

[JITERA][2025-02-09] Sync main to Jitera #911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/util/complex.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export default class Complex {
* @param {number} [imag] Imaginary number
*/
constructor(real = 0, imag = 0) {
/** @private */
this._real = real
/** @private */
this._imag = imag
}

Expand Down
78 changes: 78 additions & 0 deletions lib/util/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ export default class Graph {
*/
constructor(nodes = 0, edges = []) {
if (Array.isArray(nodes)) {
/** @private */
this._nodes = nodes
} else {
this._nodes = Array(nodes)
}
/** @private */
this._edges = edges.map(
e => new Edge(e[0] | e.from, e[1] | e.to, e instanceof Edge ? e.value0 : e.value, e.direct)
)
Expand Down Expand Up @@ -988,6 +990,20 @@ export default class Graph {

/**
* Return degree of the node.
* @overload
* @param {number} k Index of target node
* @param {boolean} [undirect] Count undirected edges
* @param {boolean | 'in' | 'out'} [direct] Count directed edges
* @returns {number} Degree of the node
*/
/**
* Return degree of the node.
* @overload
* @param {number} k Index of target node
* @param {'in' | 'out'} direct Count only directed edges.
* @returns {number} Degree of the node
*/
/**
* @param {number} k Index of target node
* @param {boolean | 'in' | 'out'} [undirect] Count undirected edges. If `in` or `out` is specified, only direct edges are counted and `direct` parameter is ignored.
* @param {boolean | 'in' | 'out'} [direct] Count directed edges
Expand Down Expand Up @@ -1015,6 +1031,20 @@ export default class Graph {

/**
* Return indexes of adjacency nodes.
* @overload
* @param {number} k Index of target node
* @param {boolean} [undirect] Check undirected edges
* @param {boolean | 'in' | 'out'} [direct] Check directed edges
* @returns {number[]} Indexes of adjacency nodes
*/
/**
* Return indexes of adjacency nodes.
* @overload
* @param {number} k Index of target node
* @param {'in' | 'out'} direct Check only directed edges
* @returns {number[]} Indexes of adjacency nodes
*/
/**
* @param {number} k Index of target node
* @param {boolean | 'in' | 'out'} [undirect] Check undirected edges. If `in` or `out` is specified, only direct edges are checked and `direct` parameter is ignored.
* @param {boolean | 'in' | 'out'} [direct] Check directed edges
Expand Down Expand Up @@ -1246,8 +1276,18 @@ export default class Graph {
return min_loop
}

/**
* Returns index of all cliques.
* @overload
* @returns {number[][][]} Index of cliques
*/
/**
* Returns index of cliques.
* @overload
* @param {number} k Size of clique
* @returns {number[][]} Index of cliques
*/
/**
* @param {number} [k] Size of clique
* @returns {number[][] | number[][][]} Index of cliques
*/
Expand Down Expand Up @@ -1524,6 +1564,17 @@ export default class Graph {

/**
* Returns the node value.
* @overload
* @param {number} k Index of the node
* @returns {unknown} Node value
*/
/**
* Returns the node value.
* @overload
* @param {number[]} [k] Index of the node
* @returns {unknown[]} Node value
*/
/**
* @param {number | number[]} [k] Index of the node
* @returns {unknown | unknown[]} Node value
*/
Expand Down Expand Up @@ -1591,6 +1642,22 @@ export default class Graph {

/**
* Returns the edges.
* @overload
* @param {number} from Index of the starting node of the edge
* @param {number} to Index of the end node of the edge
* @param {boolean} [undirect] Get undirected edges or not
* @param {boolean | 'forward' | 'backward'} [direct] Get directed edges or not
* @returns {Edge[]} Edges between `from` and `to`
*/
/**
* Returns the edges.
* @overload
* @param {number} from Index of the starting node of the edge
* @param {number} to Index of the end node of the edge
* @param {'forward' | 'backward'} direct Get only directed edges
* @returns {Edge[]} Edges between `from` and `to`
*/
/**
* @param {number} from Index of the starting node of the edge
* @param {number} to Index of the end node of the edge
* @param {boolean | 'forward' | 'backward'} [undirect] Get undirected edges or not. If `forward` or `backward` is specified, only direct edges are get and `direct` parameter is ignored.
Expand Down Expand Up @@ -3215,6 +3282,17 @@ export default class Graph {

/**
* Returns shortest path.
* @overload
* @param {null} [from] Index of start nodes
* @returns {{length: number, path: number[]}[][]} Shortest length and path for all nodes
*/
/**
* Returns shortest path.
* @overload
* @param {number} from Index of start nodes
* @returns {{length: number, prev: number, path: number[]}[]} Shortest length and path for all nodes
*/
/**
* @param {number} [from] Index of start nodes
* @returns {{length: number, prev: number, path: number[]}[] | {length: number, path: number[]}[][]} Shortest length and path for all nodes
*/
Expand Down
Loading
Loading