math-exercises 3.0.216 → 3.0.218
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/exercises/math/calcul/arithmetics/commonDivisorsList.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/commonDivisorsList.js +1 -0
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.js +5 -8
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.js +7 -17
- package/lib/exercises/math/calcul/fractions/fractionForbiddenValue.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionForbiddenValue.js +5 -6
- package/lib/exercises/math/calcul/fractions/fractionsDivision.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsDivision.js +7 -17
- package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSum.js +7 -22
- package/lib/exercises/math/calcul/fractions/fractionsSumFillInTheBlank.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumFillInTheBlank.js +7 -19
- package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.js +7 -22
- package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +7 -22
- package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.d.ts +4 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.js +7 -23
- package/lib/exercises/math/calcul/fractions/periodicWritingToFraction.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/periodicWritingToFraction.js +3 -7
- package/lib/exercises/math/calcul/fractions/simplifyFraction.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/simplifyFraction.js +6 -7
- package/lib/exercises/math/calcul/mentalCaluls/mentalDivisions.d.ts.map +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalDivisions.js +3 -4
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication101AndFriends.d.ts.map +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication101AndFriends.js +2 -4
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication11AndFriends.d.ts.map +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication11AndFriends.js +2 -4
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplicationTable.d.ts.map +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplicationTable.js +2 -4
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.d.ts.map +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.js +2 -4
- package/lib/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.d.ts.map +1 -1
- package/lib/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.js +3 -4
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.js +14 -3
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.js +14 -3
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.js +8 -5
- package/lib/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.js +14 -5
- package/lib/exercises/math/calculLitteral/equation/exp/expOfFEqualsExpOfGEquation.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/exp/expOfFEqualsExpOfGEquation.js +19 -32
- package/lib/exercises/math/calculLitteral/equation/fractionEquation.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/fractionEquation.js +10 -10
- package/lib/exercises/math/calculLitteral/factorisation/factoByXK.d.ts +0 -8
- package/lib/exercises/math/calculLitteral/factorisation/factoByXK.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factoByXK.js +223 -190
- package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.js +22 -9
- package/lib/exercises/math/calculLitteral/factorisation/index.d.ts +0 -1
- package/lib/exercises/math/calculLitteral/factorisation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/index.js +1 -1
- package/lib/exercises/math/complex/argumentFromAlgebraicComplex.d.ts.map +1 -1
- package/lib/exercises/math/complex/argumentFromAlgebraicComplex.js +10 -4
- package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.js +2 -2
- package/lib/exercises/math/functions/absolute/absoluteValueEquations.js +12 -12
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +10 -18
- package/lib/exercises/math/functions/affines/affineMeanValue.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineMeanValue.js +3 -5
- package/lib/exercises/math/functions/basics/findZeroesProductQuotient.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/findZeroesProductQuotient.js +0 -1
- package/lib/exercises/math/functions/basics/twoFunctionsEquation.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/twoFunctionsEquation.js +12 -7
- package/lib/exercises/math/functions/integral/integralExpAxPlusB.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralExpAxPlusB.js +19 -3
- package/lib/exercises/math/functions/logarithm/log10Simplifying.d.ts.map +1 -1
- package/lib/exercises/math/functions/logarithm/log10Simplifying.js +20 -6
- package/lib/exercises/math/functions/logarithm/logSimplifiying.d.ts.map +1 -1
- package/lib/exercises/math/functions/logarithm/logSimplifiying.js +14 -9
- package/lib/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.d.ts.map +1 -1
- package/lib/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.js +9 -6
- package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.js +12 -8
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.js +21 -4
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.js +4 -7
- package/lib/exercises/math/functions/trinoms/trinomialMeanValue.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/trinomialMeanValue.js +3 -5
- package/lib/exercises/math/geometry/areas/circleArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/circleArea.js +4 -2
- package/lib/exercises/math/geometry/areas/rectangleArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/rectangleArea.js +4 -2
- package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/rightTriangleArea.js +14 -11
- package/lib/exercises/math/geometry/areas/squareArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/squareArea.js +4 -2
- package/lib/exercises/math/geometry/areas/squareSideFromArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/squareSideFromArea.js +6 -4
- package/lib/exercises/math/geometry/areas/triangleArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/triangleArea.js +3 -1
- package/lib/exercises/math/geometry/areas/triangleAreaV2.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/triangleAreaV2.js +4 -2
- package/lib/exercises/math/geometry/cartesian/midpoint.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/midpoint.js +6 -11
- package/lib/exercises/math/geometry/perimeters/rectangleSideFromPerimeter.d.ts.map +1 -1
- package/lib/exercises/math/geometry/perimeters/rectangleSideFromPerimeter.js +3 -3
- package/lib/exercises/math/geometry/perimeters/squareSideFromPerimeter.d.ts.map +1 -1
- package/lib/exercises/math/geometry/perimeters/squareSideFromPerimeter.js +3 -3
- package/lib/exercises/math/geometry/vectors/vectorNormCalculation.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/vectorNormCalculation.js +3 -5
- package/lib/exercises/math/geometry/volumes/parallelepipedVolume.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/parallelepipedVolume.js +3 -4
- package/lib/exercises/math/geometry/volumes/sphereVolume.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/sphereVolume.js +3 -4
- package/lib/exercises/math/geometry/volumes/volumeOfCube.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/volumeOfCube.js +3 -4
- package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleBase.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleBase.js +3 -6
- package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleRectBase.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleRectBase.js +3 -6
- package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.d.ts.map +1 -1
- package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.js +3 -1
- package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.d.ts +11 -0
- package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.d.ts.map +1 -0
- package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.js +155 -0
- package/lib/exercises/math/graphs/graphsCheckIsConnectedUndirectedGraph.js +1 -1
- package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts +0 -2
- package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts.map +1 -1
- package/lib/exercises/math/graphs/graphsCheckIsSameGraph.js +4 -14
- package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.d.ts.map +1 -1
- package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.js +3 -1
- package/lib/exercises/math/graphs/graphsDegreeOfVertex.d.ts.map +1 -1
- package/lib/exercises/math/graphs/graphsDegreeOfVertex.js +3 -1
- package/lib/exercises/math/graphs/graphsOrderOfGraph.d.ts.map +1 -1
- package/lib/exercises/math/graphs/graphsOrderOfGraph.js +3 -1
- package/lib/exercises/math/graphs/index.d.ts +1 -1
- package/lib/exercises/math/graphs/index.d.ts.map +1 -1
- package/lib/exercises/math/graphs/index.js +1 -1
- package/lib/exercises/math/integration/fromExpr/integralFromExpr.d.ts.map +1 -1
- package/lib/exercises/math/integration/fromExpr/integralFromExpr.js +2 -0
- package/lib/exercises/math/limits/rationalFracLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/rationalFracLimit.js +9 -20
- package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.js +9 -20
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.js +11 -28
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.js +12 -27
- package/lib/exercises/math/spaceGeometry/parametricLine/lineLineRelativePositionsFromParametricLines.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/parametricLine/lineLineRelativePositionsFromParametricLines.js +56 -3
- package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlaneEquation.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlaneEquation.js +6 -0
- package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.js +3 -5
- package/lib/exercises/math/squareRoots/simpifySquareRoot.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/simpifySquareRoot.js +5 -4
- package/lib/exercises/math/squareRoots/squareRootEquation.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootEquation.js +9 -8
- package/lib/exercises/math/squareRoots/squareRootIdentities.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootIdentities.js +7 -4
- package/lib/exercises/math/squareRoots/squareRootsDistributivity.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/squareRootsDistributivity.js +7 -8
- package/lib/exercises/math/trigonometry/arcLength.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/arcLength.js +3 -8
- package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.d.ts.map +1 -1
- package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.js +0 -6
- package/lib/exercises/pc/dosage/beerLambertRandomValue.d.ts.map +1 -1
- package/lib/exercises/pc/dosage/beerLambertRandomValue.js +3 -4
- package/lib/exercises/pc/dosage/concentrationFromMassCalculation.d.ts.map +1 -1
- package/lib/exercises/pc/dosage/concentrationFromMassCalculation.js +3 -18
- package/lib/exercises/pc/energy/energyTransfer.d.ts.map +1 -1
- package/lib/exercises/pc/energy/energyTransfer.js +3 -8
- package/lib/exercises/pc/energy/thermalEnergyTransferCalculation.d.ts.map +1 -1
- package/lib/exercises/pc/energy/thermalEnergyTransferCalculation.js +3 -24
- package/lib/exercises/pc/math/proportionnalityCoeffFromLine.d.ts.map +1 -1
- package/lib/exercises/pc/math/proportionnalityCoeffFromLine.js +9 -6
- package/lib/exercises/vea/equationVEA.d.ts.map +1 -1
- package/lib/exercises/vea/equationVEA.js +2 -0
- package/lib/exercises/vea/rationalVEA.d.ts +2 -1
- package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
- package/lib/exercises/vea/rationalVEA.js +36 -2
- package/lib/exercises/vea/treeTableVEA.d.ts.map +1 -1
- package/lib/exercises/vea/treeTableVEA.js +2 -0
- package/lib/index.d.ts +3 -8
- package/lib/index.d.ts.map +1 -1
- package/lib/math/graphs/graph.d.ts +1 -1
- package/lib/math/graphs/graph.d.ts.map +1 -1
- package/lib/math/graphs/graph.js +86 -30
- package/lib/math/utils/graphs/graphRenderer.d.ts +7 -9
- package/lib/math/utils/graphs/graphRenderer.d.ts.map +1 -1
- package/lib/math/utils/graphs/graphRenderer.js +25 -117
- package/lib/tree/nodes/algebraicNode.d.ts +2 -0
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/algebraicNode.js +11 -0
- package/lib/tree/nodes/functions/log10Node.d.ts +2 -2
- package/lib/tree/nodes/functions/log10Node.d.ts.map +1 -1
- package/lib/tree/nodes/functions/log10Node.js +3 -1
- package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/logNode.js +2 -0
- package/lib/tree/nodes/operators/addNode.js +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +1 -1
- package/package.json +1 -7
package/lib/math/graphs/graph.js
CHANGED
|
@@ -265,44 +265,100 @@ export class Graph {
|
|
|
265
265
|
return visited.every((v) => v);
|
|
266
266
|
//AI CODE (Edge) }
|
|
267
267
|
}
|
|
268
|
-
|
|
268
|
+
getWeaklyConnectedSubgraphCoveringChainsAsArrIndex() {
|
|
269
269
|
const adjMatrix = (this.isDirected ? this.undirectedGraph() : this)
|
|
270
270
|
.adjacencyMatrix()
|
|
271
271
|
.elements.map((row) => row.map((elt) => elt.evaluate()));
|
|
272
|
-
//AI CODE (Edge) {
|
|
273
|
-
// Validate input
|
|
274
|
-
if (!Array.isArray(adjMatrix) || adjMatrix.length === 0) {
|
|
275
|
-
throw new Error("Adjacency matrix must be a non-empty 2D array.");
|
|
276
|
-
}
|
|
277
272
|
const n = adjMatrix.length;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
273
|
+
const linked = (i, j) => i !== j &&
|
|
274
|
+
((adjMatrix[i]?.[j] ?? 0) !== 0 || (adjMatrix[j]?.[i] ?? 0) !== 0);
|
|
275
|
+
// Voisinage non orienté
|
|
276
|
+
const neighbors = Array.from({ length: n }, (_, i) => {
|
|
277
|
+
const list = [];
|
|
278
|
+
for (let j = 0; j < n; j++)
|
|
279
|
+
if (linked(i, j))
|
|
280
|
+
list.push(j);
|
|
281
|
+
return list;
|
|
282
|
+
});
|
|
283
|
+
// 1. Composantes connexes
|
|
284
|
+
const seen = new Array(n).fill(false);
|
|
285
|
+
const components = [];
|
|
286
|
+
for (let start = 0; start < n; start++) {
|
|
287
|
+
if (seen[start])
|
|
288
|
+
continue;
|
|
289
|
+
const component = [];
|
|
290
|
+
const stack = [start];
|
|
291
|
+
seen[start] = true;
|
|
292
|
+
while (stack.length > 0) {
|
|
293
|
+
const node = stack.pop();
|
|
294
|
+
component.push(node);
|
|
295
|
+
for (const nb of neighbors[node]) {
|
|
296
|
+
if (!seen[nb]) {
|
|
297
|
+
seen[nb] = true;
|
|
298
|
+
stack.push(nb);
|
|
299
|
+
}
|
|
290
300
|
}
|
|
291
301
|
}
|
|
302
|
+
components.push(component.sort((a, b) => a - b));
|
|
292
303
|
}
|
|
293
|
-
//
|
|
294
|
-
|
|
295
|
-
if (
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
304
|
+
// 2. Chaîne couvrant une composante
|
|
305
|
+
const coveringChain = (component) => {
|
|
306
|
+
if (component.length === 1)
|
|
307
|
+
return [...component];
|
|
308
|
+
// Arbre couvrant en profondeur (donne des branches longues)
|
|
309
|
+
const tree = new Map(component.map((v) => [v, []]));
|
|
310
|
+
const inTree = new Set([component[0]]);
|
|
311
|
+
const grow = (u) => {
|
|
312
|
+
for (const v of neighbors[u]) {
|
|
313
|
+
if (!inTree.has(v)) {
|
|
314
|
+
inTree.add(v);
|
|
315
|
+
tree.get(u).push(v);
|
|
316
|
+
tree.get(v).push(u);
|
|
317
|
+
grow(v);
|
|
318
|
+
}
|
|
301
319
|
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
320
|
+
};
|
|
321
|
+
grow(component[0]);
|
|
322
|
+
// Sommet le plus éloigné (BFS dans l'arbre) + parents pour remonter la branche
|
|
323
|
+
const farthest = (src) => {
|
|
324
|
+
const parent = new Map([[src, -1]]);
|
|
325
|
+
const queue = [src];
|
|
326
|
+
for (let i = 0; i < queue.length; i++) {
|
|
327
|
+
for (const v of tree.get(queue[i])) {
|
|
328
|
+
if (!parent.has(v)) {
|
|
329
|
+
parent.set(v, queue[i]);
|
|
330
|
+
queue.push(v);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return { last: queue[queue.length - 1], parent };
|
|
335
|
+
};
|
|
336
|
+
// Diamètre de l'arbre : de a à b
|
|
337
|
+
const a = farthest(component[0]).last;
|
|
338
|
+
const { last: b, parent } = farthest(a);
|
|
339
|
+
const onDiameter = new Set();
|
|
340
|
+
for (let v = b; v !== -1; v = parent.get(v))
|
|
341
|
+
onDiameter.add(v);
|
|
342
|
+
// Parcours depuis a : les sous-arbres annexes d'abord (avec retour),
|
|
343
|
+
// la branche du diamètre en dernier (sans retour)
|
|
344
|
+
const chain = [];
|
|
345
|
+
const visit = (u, from) => {
|
|
346
|
+
chain.push(u);
|
|
347
|
+
const children = tree
|
|
348
|
+
.get(u)
|
|
349
|
+
.filter((v) => v !== from)
|
|
350
|
+
.sort((x, y) => Number(onDiameter.has(x)) - Number(onDiameter.has(y)));
|
|
351
|
+
for (const child of children) {
|
|
352
|
+
visit(child, u);
|
|
353
|
+
if (!onDiameter.has(child))
|
|
354
|
+
chain.push(u); // retour arrière
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
visit(a, -1);
|
|
358
|
+
// Normalisation : commencer par la plus petite extrémité
|
|
359
|
+
return chain[0] > chain[chain.length - 1] ? chain.reverse() : chain;
|
|
360
|
+
};
|
|
361
|
+
return components.map(coveringChain);
|
|
306
362
|
}
|
|
307
363
|
getSomePathsWithNbEdges(nbEdges, nbToFindIfPossible) {
|
|
308
364
|
const n = nbEdges;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Graph } from "../../graphs/graph.js";
|
|
2
|
-
import * as TSGraphViz from "ts-graphviz";
|
|
3
|
-
import { Engine } from "@hpcc-js/wasm-graphviz";
|
|
4
2
|
export interface GraphNode {
|
|
5
3
|
label: string;
|
|
6
4
|
x: number;
|
|
@@ -10,14 +8,14 @@ export interface GraphEdge {
|
|
|
10
8
|
from: string;
|
|
11
9
|
to: string;
|
|
12
10
|
}
|
|
11
|
+
export type RandomLayoutOptions = {
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
minDistance?: number;
|
|
15
|
+
maxAttempts?: number;
|
|
16
|
+
};
|
|
13
17
|
export declare class GraphRenderer {
|
|
14
|
-
static
|
|
15
|
-
static renderToSVG(graph: Graph, layoutEngineIn?: Engine): string;
|
|
16
|
-
static convertSVGToNodesAndEdges(strSVG: string): {
|
|
17
|
-
nodes: GraphNode[];
|
|
18
|
-
edges: GraphEdge[];
|
|
19
|
-
};
|
|
20
|
-
static renderToNodesAndEdges(graph: Graph, layoutEngineIn?: Engine): {
|
|
18
|
+
static renderToNodesAndEdges(graph: Graph, { width, height, minDistance, maxAttempts, }?: RandomLayoutOptions): {
|
|
21
19
|
nodes: GraphNode[];
|
|
22
20
|
edges: GraphEdge[];
|
|
23
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphRenderer.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/graphs/graphRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,
|
|
1
|
+
{"version":3,"file":"graphRenderer.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/graphs/graphRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,qBAAa,aAAa;IACxB,MAAM,CAAC,qBAAqB,CAC1B,KAAK,EAAE,KAAK,EACZ,EACE,KAAU,EACV,MAAW,EACX,WAAiB,EACjB,WAAiB,GAClB,GAAE,mBAAwB,GAC1B;QAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAAC,KAAK,EAAE,SAAS,EAAE,CAAA;KAAE;CAoC9C"}
|
|
@@ -1,123 +1,31 @@
|
|
|
1
|
-
import * as TSGraphViz from "ts-graphviz";
|
|
2
|
-
import { Graphviz } from "@hpcc-js/wasm-graphviz";
|
|
3
|
-
const graphviz = await Graphviz.load();
|
|
4
|
-
import { JSDOM } from "jsdom";
|
|
5
|
-
import { random } from "../../../utils/alea/random.js";
|
|
6
1
|
export class GraphRenderer {
|
|
7
|
-
static
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
static renderToNodesAndEdges(graph, { width = 10, height = 10, minDistance = 1.5, maxAttempts = 100, } = {}) {
|
|
3
|
+
// 1. Placement aléatoire des sommets, en évitant les chevauchements
|
|
4
|
+
const nodes = [];
|
|
5
|
+
for (const label of graph.vertexNames) {
|
|
6
|
+
let best = { x: 0, y: 0 };
|
|
7
|
+
let bestDist = -Infinity;
|
|
8
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
9
|
+
const x = Math.random() * width;
|
|
10
|
+
const y = Math.random() * height;
|
|
11
|
+
const dist = nodes.reduce((min, node) => Math.min(min, Math.hypot(node.x - x, node.y - y)), Infinity);
|
|
12
|
+
// on garde le candidat le plus éloigné des autres (repli si la zone est trop petite)
|
|
13
|
+
if (dist > bestDist) {
|
|
14
|
+
best = { x, y };
|
|
15
|
+
bestDist = dist;
|
|
16
|
+
}
|
|
17
|
+
if (dist >= minDistance)
|
|
18
|
+
break;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
return arrConnection
|
|
26
|
-
.map(([nameVertexStart, nameVertexEnd]) => [nameVertexStart, nameVertexEnd].join("-"))
|
|
27
|
-
.reduce((acc, strEdge) => {
|
|
28
|
-
const strEdgeReversed = strEdge.split("").toReversed().join("");
|
|
29
|
-
if (acc.includes(strEdgeReversed)) {
|
|
30
|
-
//ignore
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
acc = [...acc, strEdge];
|
|
34
|
-
}
|
|
35
|
-
return acc;
|
|
36
|
-
}, [])
|
|
37
|
-
.map((strEdge) => {
|
|
38
|
-
const [nameVertexStart, nameVertexEnd] = strEdge.split("-");
|
|
39
|
-
return [nameVertexStart, nameVertexEnd];
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
})();
|
|
43
|
-
const arrEdge = arrConnectionNoDuplicate.map(([nameVertexStart, nameVertexEnd]) => {
|
|
44
|
-
const [graphvizNodeStart, graphvizNodeEnd] = [
|
|
45
|
-
nameVertexStart,
|
|
46
|
-
nameVertexEnd,
|
|
47
|
-
].map((nameVertex) => dictGraphvizNode[nameVertex]);
|
|
48
|
-
const graphvizEdge = new TSGraphViz.Edge([graphvizNodeStart, graphvizNodeEnd], {});
|
|
49
|
-
return graphvizEdge;
|
|
50
|
-
});
|
|
51
|
-
// Add elements to the graph
|
|
52
|
-
Object.entries(dictGraphvizNode).forEach(([_, graphvizNode]) => digraph.addNode(graphvizNode));
|
|
53
|
-
arrEdge.forEach((graphvizEdge) => digraph.addEdge(graphvizEdge));
|
|
54
|
-
return digraph;
|
|
55
|
-
}
|
|
56
|
-
static renderToSVG(graph, layoutEngineIn) {
|
|
57
|
-
const digraph = GraphRenderer.convertToGraphVizGraph(graph);
|
|
58
|
-
const dot = TSGraphViz.toDot(digraph);
|
|
59
|
-
// Render DOT to SVG
|
|
60
|
-
/*
|
|
61
|
-
const arrLayoutEngine = [
|
|
62
|
-
"circo",
|
|
63
|
-
"dot",
|
|
64
|
-
"fdp",
|
|
65
|
-
"neato",
|
|
66
|
-
"nop",
|
|
67
|
-
"nop2",
|
|
68
|
-
// "osage",
|
|
69
|
-
// "patchwork",
|
|
70
|
-
"sfdp",
|
|
71
|
-
"twopi",
|
|
72
|
-
];
|
|
73
|
-
*/
|
|
74
|
-
const layoutEngine = layoutEngineIn ?? random(["fdp", "circo"]);
|
|
75
|
-
const svg = graphviz.layout(dot, "svg", layoutEngine);
|
|
76
|
-
return svg;
|
|
77
|
-
}
|
|
78
|
-
static convertSVGToNodesAndEdges(strSVG) {
|
|
79
|
-
function parseSvgGraph(svgString) {
|
|
80
|
-
const domParser = new new JSDOM().window.DOMParser();
|
|
81
|
-
const doc = domParser.parseFromString(svgString, "image/svg+xml");
|
|
82
|
-
const svgEl = doc.querySelector("svg");
|
|
83
|
-
const height = parseFloat(svgEl?.getAttribute("height") ?? "0");
|
|
84
|
-
// Translation du groupe racine (pattern classique Graphviz)
|
|
85
|
-
const graphGroup = doc.querySelector("g.graph") ?? doc.querySelector("svg > g");
|
|
86
|
-
const transform = graphGroup?.getAttribute("transform") ?? "";
|
|
87
|
-
const match = transform.match(/translate\(([-\d.]+)[ ,]([-\d.]+)\)/);
|
|
88
|
-
const [tx, ty] = match
|
|
89
|
-
? [parseFloat(match[1]), parseFloat(match[2])]
|
|
90
|
-
: [0, 0];
|
|
91
|
-
// Sommets
|
|
92
|
-
const nodes = Array.from(doc.querySelectorAll("g.node")).map((g) => {
|
|
93
|
-
const ellipse = g.querySelector("ellipse");
|
|
94
|
-
const text = g.querySelector("text");
|
|
95
|
-
const label = text?.textContent?.trim() ??
|
|
96
|
-
g.querySelector("title")?.textContent?.trim() ??
|
|
97
|
-
"";
|
|
98
|
-
const cx = parseFloat(ellipse?.getAttribute("cx") ?? "0");
|
|
99
|
-
const cy = parseFloat(ellipse?.getAttribute("cy") ?? "0");
|
|
100
|
-
return {
|
|
101
|
-
label,
|
|
102
|
-
x: cx + tx,
|
|
103
|
-
y: height - (cy + ty), // flip vertical SVG -> GeoGebra
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
// Arêtes : lues directement depuis le <title> de chaque g.edge (ex: "A->B")
|
|
107
|
-
const edges = Array.from(doc.querySelectorAll("g.edge"))
|
|
108
|
-
.map((g) => g.querySelector("title")?.textContent?.trim() ?? "")
|
|
109
|
-
.map((title) => {
|
|
110
|
-
const [from, to] = title.split(/->|->/).map((s) => s.trim());
|
|
111
|
-
return { from, to };
|
|
112
|
-
})
|
|
113
|
-
.filter((e) => Boolean(e.from && e.to));
|
|
114
|
-
return { nodes, edges };
|
|
20
|
+
nodes.push({ label, ...best });
|
|
115
21
|
}
|
|
116
|
-
|
|
22
|
+
// 2. Arêtes (une seule fois par paire si le graphe n'est pas orienté)
|
|
23
|
+
const indexOf = new Map(graph.vertexNames.map((name, i) => [name, i]));
|
|
24
|
+
const edges = graph
|
|
25
|
+
.arrConnection()
|
|
26
|
+
.filter(([from, to, isConnection]) => isConnection &&
|
|
27
|
+
(graph.isDirected || indexOf.get(from) <= indexOf.get(to)))
|
|
28
|
+
.map(([from, to]) => ({ from, to }));
|
|
117
29
|
return { nodes, edges };
|
|
118
30
|
}
|
|
119
|
-
static renderToNodesAndEdges(graph, layoutEngineIn) {
|
|
120
|
-
const strSVG = this.renderToSVG(graph, layoutEngineIn);
|
|
121
|
-
return this.convertSVGToNodesAndEdges(strSVG);
|
|
122
|
-
}
|
|
123
31
|
}
|
|
@@ -21,6 +21,7 @@ export type SimplifyOptions = {
|
|
|
21
21
|
forbidPowerMultiply?: boolean;
|
|
22
22
|
forbidPowerDivision?: boolean;
|
|
23
23
|
forbidPowerPower?: boolean;
|
|
24
|
+
forbidLogSimplify?: boolean;
|
|
24
25
|
};
|
|
25
26
|
export type EvaluateOptions = {
|
|
26
27
|
degreeMode?: boolean;
|
|
@@ -41,4 +42,5 @@ export declare abstract class CAlgebraicNode {
|
|
|
41
42
|
private static toString;
|
|
42
43
|
}
|
|
43
44
|
export declare const isAlgebraicNode: (node: Node) => node is AlgebraicNode;
|
|
45
|
+
export declare const isFactorizedNode: (node: Node) => node is AlgebraicNode;
|
|
44
46
|
//# sourceMappingURL=algebraicNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algebraicNode.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/algebraicNode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"algebraicNode.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/algebraicNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAI9C,MAAM,MAAM,eAAe,GAAG;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAG7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AACF,MAAM,WAAW,aAAc,SAAQ,IAAI;IACzC,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,eAAe,KAAK,MAAM,CAAC;IAC5E,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,aAAa,CAAC;IAC7E,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,aAAa,EAAE,CAAC;IAC3D,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,aAAa,CAAC;IACnE,MAAM,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,aAAa,CAAC;IAChD,mBAAmB,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,KAAK,MAAM,CAAC;IACxD,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC;AACD,8BAAsB,cAAc;;IAElC,OAAO,CAAC,MAAM,CAAC,QAAQ;CAGxB;AACD,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,KAAG,IAAI,IAAI,aACI,CAAC;AAE1D,eAAO,MAAM,gBAAgB,GAAI,MAAM,IAAI,KAAG,IAAI,IAAI,aASrD,CAAC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { isOppositeNode } from "./functions/oppositeNode.js";
|
|
2
|
+
import { isMultiplyNode } from "./operators/multiplyNode.js";
|
|
3
|
+
import { isPowerNode, isSquareNode } from "./operators/powerNode.js";
|
|
1
4
|
export class CAlgebraicNode {
|
|
2
5
|
constructor() { }
|
|
3
6
|
static toString() {
|
|
@@ -5,3 +8,11 @@ export class CAlgebraicNode {
|
|
|
5
8
|
}
|
|
6
9
|
}
|
|
7
10
|
export const isAlgebraicNode = (node) => Object.prototype.hasOwnProperty.call(node, "isNumeric");
|
|
11
|
+
export const isFactorizedNode = (node) => {
|
|
12
|
+
return (isMultiplyNode(node) ||
|
|
13
|
+
isPowerNode(node) ||
|
|
14
|
+
isSquareNode(node) ||
|
|
15
|
+
(isOppositeNode(node) && isMultiplyNode(node.child)) ||
|
|
16
|
+
(isOppositeNode(node) && isPowerNode(node.child)) ||
|
|
17
|
+
(isOppositeNode(node) && isSquareNode(node.child)));
|
|
18
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeOptions, NodeType } from "../node.js";
|
|
2
2
|
import { FunctionNode, FunctionsIds } from "./functionNode.js";
|
|
3
|
-
import { AlgebraicNode } from "../algebraicNode.js";
|
|
3
|
+
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
|
|
4
4
|
export declare function isLog10Node(a: Node): a is Log10Node;
|
|
5
5
|
export declare const log10: (a: AlgebraicNode | number | string) => Log10Node;
|
|
6
6
|
export declare class Log10Node implements FunctionNode {
|
|
@@ -22,7 +22,7 @@ export declare class Log10Node implements FunctionNode {
|
|
|
22
22
|
toEquivalentNodes(): AlgebraicNode[];
|
|
23
23
|
toSignInequationTex(): string;
|
|
24
24
|
toAllValidTexs(): string[];
|
|
25
|
-
simplify(): AlgebraicNode;
|
|
25
|
+
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
26
26
|
evaluate(vars?: Record<string, number>): number;
|
|
27
27
|
equals(node: AlgebraicNode): boolean;
|
|
28
28
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): Log10Node;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log10Node.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/log10Node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"log10Node.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/log10Node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAMrE,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,SAAS,CAEnD;AAED,eAAO,MAAM,KAAK,GAAI,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,cAIvD,CAAC;AACF,qBAAa,SAAU,YAAW,YAAY;IAC5C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAGtB,mBAAmB;IAQnB,KAAK,IAAI,MAAM;IAaf,iBAAiB,IAAI,aAAa,EAAE;IAQpC,mBAAmB;IAOnB,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAkC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAGpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAGxD,UAAU,IAAI,aAAa;CAG5B"}
|
|
@@ -78,9 +78,11 @@ export class Log10Node {
|
|
|
78
78
|
toAllValidTexs() {
|
|
79
79
|
return this.toEquivalentNodes().map((node) => node.toTex());
|
|
80
80
|
}
|
|
81
|
-
simplify() {
|
|
81
|
+
simplify(opts) {
|
|
82
82
|
const simplifiedChild = this.child.simplify();
|
|
83
83
|
const copy = new Log10Node(simplifiedChild, this.opts);
|
|
84
|
+
if (opts?.forbidLogSimplify)
|
|
85
|
+
return copy;
|
|
84
86
|
if (isNumberNode(simplifiedChild)) {
|
|
85
87
|
const value = simplifiedChild.value;
|
|
86
88
|
const log10 = Math.log10(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/logNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQrE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AAED,eAAO,MAAM,IAAI,GAAI,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,YAItD,CAAC;AAEF,qBAAa,OAAQ,YAAW,YAAY;IAC1C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAGtB,mBAAmB;IAQnB,KAAK,IAAI,MAAM;IAaf,iBAAiB,IAAI,aAAa,EAAE;IAQpC,mBAAmB;IAOnB,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;
|
|
1
|
+
{"version":3,"file":"logNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/logNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQrE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AAED,eAAO,MAAM,IAAI,GAAI,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,YAItD,CAAC;AAEF,qBAAa,OAAQ,YAAW,YAAY;IAC1C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,aAAa;;;;;;IAMb,YAAY,IAAI,MAAM;IAGtB,mBAAmB;IAQnB,KAAK,IAAI,MAAM;IAaf,iBAAiB,IAAI,aAAa,EAAE;IAQpC,mBAAmB;IAOnB,cAAc,IAAI,MAAM,EAAE;IAG1B,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAqC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAGpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAGxD,UAAU,IAAI,aAAa;CAG5B"}
|
|
@@ -81,6 +81,8 @@ export class LogNode {
|
|
|
81
81
|
simplify(opts) {
|
|
82
82
|
const simplifiedChild = this.child.simplify(opts);
|
|
83
83
|
const copy = new LogNode(simplifiedChild, this.opts);
|
|
84
|
+
if (opts?.forbidLogSimplify)
|
|
85
|
+
return copy; //on autorise la simplification du child mais pas les formules de simpliifications du log en elles memes
|
|
84
86
|
if (isNumberNode(simplifiedChild)) {
|
|
85
87
|
const value = simplifiedChild.value;
|
|
86
88
|
if (value <= 0)
|
|
@@ -313,7 +313,7 @@ const addSort = (a, b, opts) => {
|
|
|
313
313
|
parsedA.variable.localeCompare(parsedB.variable));
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
return
|
|
316
|
+
return Number(isNumberNode(b)) - Number(isNumberNode(a));
|
|
317
317
|
};
|
|
318
318
|
const addSimplifyFrac = (a, b, opts) => {
|
|
319
319
|
if (isFractionNode(a) &&
|
|
@@ -102,7 +102,7 @@ export class FractionNode {
|
|
|
102
102
|
const simp = this.simplify();
|
|
103
103
|
if (isNumberNode(simp))
|
|
104
104
|
return true;
|
|
105
|
-
let denum = simp.
|
|
105
|
+
let denum = simp.rightChild.evaluate();
|
|
106
106
|
let counter = 0;
|
|
107
107
|
while (denum % 2 === 0) {
|
|
108
108
|
counter++;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "math-exercises",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.218",
|
|
5
5
|
"description": "Math exercises generator for middle school and high school",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"files": [
|
|
@@ -28,22 +28,16 @@
|
|
|
28
28
|
"author": "Heureux Hasard",
|
|
29
29
|
"license": "ISC",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@flatten-js/core": "^1.6.14",
|
|
32
|
-
"@hpcc-js/wasm-graphviz": "^1.29.1",
|
|
33
31
|
"d3-node": "^4.0.1",
|
|
34
|
-
"jsdom": "^29.1.1",
|
|
35
32
|
"katex": "^0.16.21",
|
|
36
33
|
"lodash.isequal": "^4.5.0",
|
|
37
|
-
"ts-graphviz": "^3.0.7",
|
|
38
34
|
"uuidv4": "^6.2.13"
|
|
39
35
|
},
|
|
40
36
|
"devDependencies": {
|
|
41
37
|
"@eslint/js": "^9.34.0",
|
|
42
38
|
"@types/cors": "^2.8.13",
|
|
43
|
-
"@types/deasync": "^0.1.5",
|
|
44
39
|
"@types/express": "^4.17.17",
|
|
45
40
|
"@types/jest": "^29.5.6",
|
|
46
|
-
"@types/jsdom": "^30.0.0",
|
|
47
41
|
"@types/lodash.isequal": "^4.5.8",
|
|
48
42
|
"@types/node": "^20.10.6",
|
|
49
43
|
"body-parser": "^1.20.2",
|