@nshiab/simple-data-analysis-core 2.0.9 → 2.1.0
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/esm/class/SDAError.d.ts +6 -6
- package/esm/class/SDAError.js +6 -6
- package/esm/class/Simple.d.ts +9 -9
- package/esm/class/Simple.js +9 -9
- package/esm/class/SimpleDB.d.ts +80 -76
- package/esm/class/SimpleDB.d.ts.map +1 -1
- package/esm/class/SimpleDB.js +80 -76
- package/esm/class/SimpleTable.d.ts +2795 -1139
- package/esm/class/SimpleTable.d.ts.map +1 -1
- package/esm/class/SimpleTable.js +2781 -1149
- package/esm/helpers/buildApproximateMutualReachabilityMst.d.ts +45 -0
- package/esm/helpers/buildApproximateMutualReachabilityMst.d.ts.map +1 -0
- package/esm/helpers/buildApproximateMutualReachabilityMst.js +212 -0
- package/esm/helpers/buildChronologicalGraphComponentsSql.d.ts +14 -0
- package/esm/helpers/buildChronologicalGraphComponentsSql.d.ts.map +1 -0
- package/esm/helpers/buildChronologicalGraphComponentsSql.js +167 -0
- package/esm/helpers/buildExactMutualReachabilityMst.d.ts +28 -0
- package/esm/helpers/buildExactMutualReachabilityMst.d.ts.map +1 -0
- package/esm/helpers/buildExactMutualReachabilityMst.js +97 -0
- package/esm/helpers/buildGraphTemporalCostStateSql.d.ts +12 -0
- package/esm/helpers/buildGraphTemporalCostStateSql.d.ts.map +1 -0
- package/esm/helpers/buildGraphTemporalCostStateSql.js +86 -0
- package/esm/helpers/buildGraphTemporalReachabilitySql.d.ts +13 -0
- package/esm/helpers/buildGraphTemporalReachabilitySql.d.ts.map +1 -0
- package/esm/helpers/buildGraphTemporalReachabilitySql.js +70 -0
- package/esm/helpers/buildSparseMutualReachabilityMst.d.ts +10 -0
- package/esm/helpers/buildSparseMutualReachabilityMst.d.ts.map +1 -0
- package/esm/helpers/buildSparseMutualReachabilityMst.js +47 -0
- package/esm/helpers/buildUmapGraph.d.ts +2 -5
- package/esm/helpers/buildUmapGraph.d.ts.map +1 -1
- package/esm/helpers/buildUmapGraph.js +6 -100
- package/esm/helpers/buildVectorNeighbors.d.ts +45 -0
- package/esm/helpers/buildVectorNeighbors.d.ts.map +1 -0
- package/esm/helpers/buildVectorNeighbors.js +170 -0
- package/esm/helpers/buildWeakGraphComponentsSql.d.ts +3 -0
- package/esm/helpers/buildWeakGraphComponentsSql.d.ts.map +1 -0
- package/esm/helpers/buildWeakGraphComponentsSql.js +32 -0
- package/esm/helpers/camelCase.d.ts +7 -5
- package/esm/helpers/camelCase.d.ts.map +1 -1
- package/esm/helpers/camelCase.js +7 -5
- package/esm/helpers/capitalize.d.ts +6 -4
- package/esm/helpers/capitalize.d.ts.map +1 -1
- package/esm/helpers/capitalize.js +6 -4
- package/esm/helpers/clusterHdbscan.d.ts +18 -0
- package/esm/helpers/clusterHdbscan.d.ts.map +1 -0
- package/esm/helpers/clusterHdbscan.js +342 -0
- package/esm/helpers/computeCovariance.d.ts +16 -0
- package/esm/helpers/computeCovariance.d.ts.map +1 -0
- package/esm/helpers/computeCovariance.js +99 -0
- package/esm/helpers/computeMahalanobisDistances.d.ts +14 -0
- package/esm/helpers/computeMahalanobisDistances.d.ts.map +1 -0
- package/esm/helpers/computeMahalanobisDistances.js +87 -0
- package/esm/helpers/createDirectory.d.ts +4 -3
- package/esm/helpers/createDirectory.d.ts.map +1 -1
- package/esm/helpers/createDirectory.js +4 -3
- package/esm/helpers/dataToArrays.d.ts +6 -4
- package/esm/helpers/dataToArrays.d.ts.map +1 -1
- package/esm/helpers/dataToArrays.js +6 -4
- package/esm/helpers/extractTypes.d.ts +1 -1
- package/esm/helpers/extractTypes.js +4 -9
- package/esm/helpers/factorCovariance.d.ts +17 -0
- package/esm/helpers/factorCovariance.d.ts.map +1 -0
- package/esm/helpers/factorCovariance.js +189 -0
- package/esm/helpers/findGeoColumn.d.ts +6 -4
- package/esm/helpers/findGeoColumn.d.ts.map +1 -1
- package/esm/helpers/findGeoColumn.js +6 -4
- package/esm/helpers/findGeoColumnFromSchema.d.ts +8 -5
- package/esm/helpers/findGeoColumnFromSchema.d.ts.map +1 -1
- package/esm/helpers/findGeoColumnFromSchema.js +8 -5
- package/esm/helpers/formatDate.d.ts +12 -6
- package/esm/helpers/formatDate.d.ts.map +1 -1
- package/esm/helpers/formatDate.js +12 -6
- package/esm/helpers/formatMissingTables.d.ts +8 -5
- package/esm/helpers/formatMissingTables.d.ts.map +1 -1
- package/esm/helpers/formatMissingTables.js +8 -5
- package/esm/helpers/formatNumber.d.ts +19 -10
- package/esm/helpers/formatNumber.d.ts.map +1 -1
- package/esm/helpers/formatNumber.js +32 -17
- package/esm/helpers/getGraphEdgeIdColumn.d.ts +9 -0
- package/esm/helpers/getGraphEdgeIdColumn.d.ts.map +1 -0
- package/esm/helpers/getGraphEdgeIdColumn.js +25 -0
- package/esm/helpers/getGraphEndpointColumns.d.ts +11 -0
- package/esm/helpers/getGraphEndpointColumns.d.ts.map +1 -0
- package/esm/helpers/getGraphEndpointColumns.js +160 -0
- package/esm/helpers/getGraphWeightColumn.d.ts +10 -0
- package/esm/helpers/getGraphWeightColumn.d.ts.map +1 -0
- package/esm/helpers/getGraphWeightColumn.js +40 -0
- package/esm/helpers/graphRouteResultSchema.d.ts +4 -0
- package/esm/helpers/graphRouteResultSchema.d.ts.map +1 -0
- package/esm/helpers/graphRouteResultSchema.js +12 -0
- package/esm/helpers/graphRouteResultSelect.d.ts +4 -0
- package/esm/helpers/graphRouteResultSelect.d.ts.map +1 -0
- package/esm/helpers/graphRouteResultSelect.js +22 -0
- package/esm/helpers/hasGeometryColumn.d.ts +4 -3
- package/esm/helpers/hasGeometryColumn.d.ts.map +1 -1
- package/esm/helpers/hasGeometryColumn.js +4 -3
- package/esm/helpers/inspectGraphConnectivity.d.ts +10 -0
- package/esm/helpers/inspectGraphConnectivity.d.ts.map +1 -0
- package/esm/helpers/inspectGraphConnectivity.js +55 -0
- package/esm/helpers/mergeOptions.d.ts +24 -13
- package/esm/helpers/mergeOptions.d.ts.map +1 -1
- package/esm/helpers/mergeOptions.js +24 -13
- package/esm/helpers/parseValue.d.ts +6 -4
- package/esm/helpers/parseValue.d.ts.map +1 -1
- package/esm/helpers/parseValue.js +6 -4
- package/esm/helpers/prepareGraphRouteSql.d.ts +31 -0
- package/esm/helpers/prepareGraphRouteSql.d.ts.map +1 -0
- package/esm/helpers/prepareGraphRouteSql.js +86 -0
- package/esm/helpers/prepareGraphStarts.d.ts +9 -0
- package/esm/helpers/prepareGraphStarts.d.ts.map +1 -0
- package/esm/helpers/prepareGraphStarts.js +68 -0
- package/esm/helpers/prepareGraphTemporalSql.d.ts +28 -0
- package/esm/helpers/prepareGraphTemporalSql.d.ts.map +1 -0
- package/esm/helpers/prepareGraphTemporalSql.js +154 -0
- package/esm/helpers/prepareGraphTraversal.d.ts +19 -0
- package/esm/helpers/prepareGraphTraversal.d.ts.map +1 -0
- package/esm/helpers/prepareGraphTraversal.js +79 -0
- package/esm/helpers/prepareNumericFeatures.d.ts +41 -0
- package/esm/helpers/prepareNumericFeatures.d.ts.map +1 -0
- package/esm/helpers/prepareNumericFeatures.js +210 -0
- package/esm/helpers/prettyDuration.d.ts +14 -8
- package/esm/helpers/prettyDuration.d.ts.map +1 -1
- package/esm/helpers/prettyDuration.js +14 -8
- package/esm/helpers/printTable.d.ts +18 -13
- package/esm/helpers/printTable.d.ts.map +1 -1
- package/esm/helpers/printTable.js +18 -13
- package/esm/helpers/publishPreparedColumns.d.ts +37 -0
- package/esm/helpers/publishPreparedColumns.d.ts.map +1 -0
- package/esm/helpers/publishPreparedColumns.js +113 -0
- package/esm/helpers/queryDB.d.ts +24 -13
- package/esm/helpers/queryDB.d.ts.map +1 -1
- package/esm/helpers/queryDB.js +24 -13
- package/esm/helpers/queueAsyncBarrier.d.ts +12 -7
- package/esm/helpers/queueAsyncBarrier.d.ts.map +1 -1
- package/esm/helpers/queueAsyncBarrier.js +12 -7
- package/esm/helpers/queueGraphResult.d.ts +18 -0
- package/esm/helpers/queueGraphResult.d.ts.map +1 -0
- package/esm/helpers/queueGraphResult.js +39 -0
- package/esm/helpers/quoteIdentifier.d.ts +4 -3
- package/esm/helpers/quoteIdentifier.d.ts.map +1 -1
- package/esm/helpers/quoteIdentifier.js +4 -3
- package/esm/helpers/quoteQualifiedIdentifier.d.ts +6 -4
- package/esm/helpers/quoteQualifiedIdentifier.d.ts.map +1 -1
- package/esm/helpers/quoteQualifiedIdentifier.js +6 -4
- package/esm/helpers/runQuery.d.ts.map +1 -1
- package/esm/helpers/runQuery.js +17 -3
- package/esm/helpers/selectFuzzyReplacements.d.ts +11 -0
- package/esm/helpers/selectFuzzyReplacements.d.ts.map +1 -0
- package/esm/helpers/selectFuzzyReplacements.js +124 -0
- package/esm/helpers/stabilizeCosineVectors.d.ts +14 -0
- package/esm/helpers/stabilizeCosineVectors.d.ts.map +1 -0
- package/esm/helpers/stabilizeCosineVectors.js +34 -0
- package/esm/helpers/stringToArray.d.ts +4 -3
- package/esm/helpers/stringToArray.d.ts.map +1 -1
- package/esm/helpers/stringToArray.js +4 -3
- package/esm/helpers/updateColumnsWithJS.d.ts +12 -6
- package/esm/helpers/updateColumnsWithJS.d.ts.map +1 -1
- package/esm/helpers/updateColumnsWithJS.js +12 -6
- package/esm/helpers/validateGraphRouteResultSchema.d.ts +4 -0
- package/esm/helpers/validateGraphRouteResultSchema.d.ts.map +1 -0
- package/esm/helpers/validateGraphRouteResultSchema.js +13 -0
- package/esm/helpers/validateGraphTemporalEvents.d.ts +7 -0
- package/esm/helpers/validateGraphTemporalEvents.d.ts.map +1 -0
- package/esm/helpers/validateGraphTemporalEvents.js +47 -0
- package/esm/helpers/validateNumericalAnalysis.d.ts +10 -6
- package/esm/helpers/validateNumericalAnalysis.d.ts.map +1 -1
- package/esm/helpers/validateNumericalAnalysis.js +10 -6
- package/esm/helpers/validateVectorRowIds.d.ts +4 -0
- package/esm/helpers/validateVectorRowIds.d.ts.map +1 -0
- package/esm/helpers/validateVectorRowIds.js +16 -0
- package/esm/helpers/vectorDistanceExpression.d.ts +6 -0
- package/esm/helpers/vectorDistanceExpression.d.ts.map +1 -0
- package/esm/helpers/vectorDistanceExpression.js +11 -0
- package/esm/helpers/wrapString.d.ts +10 -7
- package/esm/helpers/wrapString.d.ts.map +1 -1
- package/esm/helpers/wrapString.js +10 -7
- package/esm/methods/addId.d.ts +5 -0
- package/esm/methods/addId.d.ts.map +1 -0
- package/esm/methods/addId.js +38 -0
- package/esm/methods/commonNeighbors.d.ts +10 -0
- package/esm/methods/commonNeighbors.d.ts.map +1 -0
- package/esm/methods/commonNeighbors.js +101 -0
- package/esm/methods/connectedComponents.d.ts +9 -0
- package/esm/methods/connectedComponents.d.ts.map +1 -0
- package/esm/methods/connectedComponents.js +147 -0
- package/esm/methods/degree.d.ts +9 -0
- package/esm/methods/degree.d.ts.map +1 -0
- package/esm/methods/degree.js +135 -0
- package/esm/methods/distances.d.ts +12 -0
- package/esm/methods/distances.d.ts.map +1 -0
- package/esm/methods/distances.js +164 -0
- package/esm/methods/findCycles.d.ts +12 -0
- package/esm/methods/findCycles.d.ts.map +1 -0
- package/esm/methods/findCycles.js +330 -0
- package/esm/methods/fuzzyClean.d.ts.map +1 -1
- package/esm/methods/fuzzyClean.js +17 -136
- package/esm/methods/fuzzyJoin.js +70 -16
- package/esm/methods/getTypes.d.ts +1 -1
- package/esm/methods/hdbscan.d.ts +5 -0
- package/esm/methods/hdbscan.d.ts.map +1 -0
- package/esm/methods/hdbscan.js +208 -0
- package/esm/methods/mahalanobis.d.ts +5 -0
- package/esm/methods/mahalanobis.d.ts.map +1 -0
- package/esm/methods/mahalanobis.js +92 -0
- package/esm/methods/neighbors.d.ts +9 -0
- package/esm/methods/neighbors.d.ts.map +1 -0
- package/esm/methods/neighbors.js +81 -0
- package/esm/methods/normalizeVector.d.ts +5 -0
- package/esm/methods/normalizeVector.d.ts.map +1 -0
- package/esm/methods/normalizeVector.js +132 -0
- package/esm/methods/paths.d.ts +12 -0
- package/esm/methods/paths.d.ts.map +1 -0
- package/esm/methods/paths.js +287 -0
- package/esm/methods/reachable.d.ts +11 -0
- package/esm/methods/reachable.d.ts.map +1 -0
- package/esm/methods/reachable.js +131 -0
- package/esm/methods/rowToVector.d.ts +5 -0
- package/esm/methods/rowToVector.d.ts.map +1 -0
- package/esm/methods/rowToVector.js +77 -0
- package/esm/methods/shortestPath.d.ts +12 -0
- package/esm/methods/shortestPath.d.ts.map +1 -0
- package/esm/methods/shortestPath.js +337 -0
- package/esm/methods/topologicalSort.d.ts +7 -0
- package/esm/methods/topologicalSort.d.ts.map +1 -0
- package/esm/methods/topologicalSort.js +164 -0
- package/llm.md +2106 -143
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/script/class/SDAError.d.ts +6 -6
- package/script/class/SDAError.js +6 -6
- package/script/class/Simple.d.ts +9 -9
- package/script/class/Simple.js +9 -9
- package/script/class/SimpleDB.d.ts +80 -76
- package/script/class/SimpleDB.d.ts.map +1 -1
- package/script/class/SimpleDB.js +80 -76
- package/script/class/SimpleTable.d.ts +2795 -1139
- package/script/class/SimpleTable.d.ts.map +1 -1
- package/script/class/SimpleTable.js +2781 -1149
- package/script/helpers/buildApproximateMutualReachabilityMst.d.ts +45 -0
- package/script/helpers/buildApproximateMutualReachabilityMst.d.ts.map +1 -0
- package/script/helpers/buildApproximateMutualReachabilityMst.js +219 -0
- package/script/helpers/buildChronologicalGraphComponentsSql.d.ts +14 -0
- package/script/helpers/buildChronologicalGraphComponentsSql.d.ts.map +1 -0
- package/script/helpers/buildChronologicalGraphComponentsSql.js +174 -0
- package/script/helpers/buildExactMutualReachabilityMst.d.ts +28 -0
- package/script/helpers/buildExactMutualReachabilityMst.d.ts.map +1 -0
- package/script/helpers/buildExactMutualReachabilityMst.js +103 -0
- package/script/helpers/buildGraphTemporalCostStateSql.d.ts +12 -0
- package/script/helpers/buildGraphTemporalCostStateSql.d.ts.map +1 -0
- package/script/helpers/buildGraphTemporalCostStateSql.js +92 -0
- package/script/helpers/buildGraphTemporalReachabilitySql.d.ts +13 -0
- package/script/helpers/buildGraphTemporalReachabilitySql.d.ts.map +1 -0
- package/script/helpers/buildGraphTemporalReachabilitySql.js +76 -0
- package/script/helpers/buildSparseMutualReachabilityMst.d.ts +10 -0
- package/script/helpers/buildSparseMutualReachabilityMst.d.ts.map +1 -0
- package/script/helpers/buildSparseMutualReachabilityMst.js +50 -0
- package/script/helpers/buildUmapGraph.d.ts +2 -5
- package/script/helpers/buildUmapGraph.d.ts.map +1 -1
- package/script/helpers/buildUmapGraph.js +6 -100
- package/script/helpers/buildVectorNeighbors.d.ts +45 -0
- package/script/helpers/buildVectorNeighbors.d.ts.map +1 -0
- package/script/helpers/buildVectorNeighbors.js +176 -0
- package/script/helpers/buildWeakGraphComponentsSql.d.ts +3 -0
- package/script/helpers/buildWeakGraphComponentsSql.d.ts.map +1 -0
- package/script/helpers/buildWeakGraphComponentsSql.js +38 -0
- package/script/helpers/camelCase.d.ts +7 -5
- package/script/helpers/camelCase.d.ts.map +1 -1
- package/script/helpers/camelCase.js +7 -5
- package/script/helpers/capitalize.d.ts +6 -4
- package/script/helpers/capitalize.d.ts.map +1 -1
- package/script/helpers/capitalize.js +6 -4
- package/script/helpers/clusterHdbscan.d.ts +18 -0
- package/script/helpers/clusterHdbscan.d.ts.map +1 -0
- package/script/helpers/clusterHdbscan.js +346 -0
- package/script/helpers/computeCovariance.d.ts +16 -0
- package/script/helpers/computeCovariance.d.ts.map +1 -0
- package/script/helpers/computeCovariance.js +105 -0
- package/script/helpers/computeMahalanobisDistances.d.ts +14 -0
- package/script/helpers/computeMahalanobisDistances.d.ts.map +1 -0
- package/script/helpers/computeMahalanobisDistances.js +93 -0
- package/script/helpers/createDirectory.d.ts +4 -3
- package/script/helpers/createDirectory.d.ts.map +1 -1
- package/script/helpers/createDirectory.js +4 -3
- package/script/helpers/dataToArrays.d.ts +6 -4
- package/script/helpers/dataToArrays.d.ts.map +1 -1
- package/script/helpers/dataToArrays.js +6 -4
- package/script/helpers/extractTypes.d.ts +1 -1
- package/script/helpers/extractTypes.js +4 -9
- package/script/helpers/factorCovariance.d.ts +17 -0
- package/script/helpers/factorCovariance.d.ts.map +1 -0
- package/script/helpers/factorCovariance.js +194 -0
- package/script/helpers/findGeoColumn.d.ts +6 -4
- package/script/helpers/findGeoColumn.d.ts.map +1 -1
- package/script/helpers/findGeoColumn.js +6 -4
- package/script/helpers/findGeoColumnFromSchema.d.ts +8 -5
- package/script/helpers/findGeoColumnFromSchema.d.ts.map +1 -1
- package/script/helpers/findGeoColumnFromSchema.js +8 -5
- package/script/helpers/formatDate.d.ts +12 -6
- package/script/helpers/formatDate.d.ts.map +1 -1
- package/script/helpers/formatDate.js +12 -6
- package/script/helpers/formatMissingTables.d.ts +8 -5
- package/script/helpers/formatMissingTables.d.ts.map +1 -1
- package/script/helpers/formatMissingTables.js +8 -5
- package/script/helpers/formatNumber.d.ts +19 -10
- package/script/helpers/formatNumber.d.ts.map +1 -1
- package/script/helpers/formatNumber.js +32 -17
- package/script/helpers/getGraphEdgeIdColumn.d.ts +9 -0
- package/script/helpers/getGraphEdgeIdColumn.d.ts.map +1 -0
- package/script/helpers/getGraphEdgeIdColumn.js +31 -0
- package/script/helpers/getGraphEndpointColumns.d.ts +11 -0
- package/script/helpers/getGraphEndpointColumns.d.ts.map +1 -0
- package/script/helpers/getGraphEndpointColumns.js +166 -0
- package/script/helpers/getGraphWeightColumn.d.ts +10 -0
- package/script/helpers/getGraphWeightColumn.d.ts.map +1 -0
- package/script/helpers/getGraphWeightColumn.js +46 -0
- package/script/helpers/graphRouteResultSchema.d.ts +4 -0
- package/script/helpers/graphRouteResultSchema.d.ts.map +1 -0
- package/script/helpers/graphRouteResultSchema.js +18 -0
- package/script/helpers/graphRouteResultSelect.d.ts +4 -0
- package/script/helpers/graphRouteResultSelect.d.ts.map +1 -0
- package/script/helpers/graphRouteResultSelect.js +28 -0
- package/script/helpers/hasGeometryColumn.d.ts +4 -3
- package/script/helpers/hasGeometryColumn.d.ts.map +1 -1
- package/script/helpers/hasGeometryColumn.js +4 -3
- package/script/helpers/inspectGraphConnectivity.d.ts +10 -0
- package/script/helpers/inspectGraphConnectivity.d.ts.map +1 -0
- package/script/helpers/inspectGraphConnectivity.js +58 -0
- package/script/helpers/mergeOptions.d.ts +24 -13
- package/script/helpers/mergeOptions.d.ts.map +1 -1
- package/script/helpers/mergeOptions.js +24 -13
- package/script/helpers/parseValue.d.ts +6 -4
- package/script/helpers/parseValue.d.ts.map +1 -1
- package/script/helpers/parseValue.js +6 -4
- package/script/helpers/prepareGraphRouteSql.d.ts +31 -0
- package/script/helpers/prepareGraphRouteSql.d.ts.map +1 -0
- package/script/helpers/prepareGraphRouteSql.js +127 -0
- package/script/helpers/prepareGraphStarts.d.ts +9 -0
- package/script/helpers/prepareGraphStarts.d.ts.map +1 -0
- package/script/helpers/prepareGraphStarts.js +71 -0
- package/script/helpers/prepareGraphTemporalSql.d.ts +28 -0
- package/script/helpers/prepareGraphTemporalSql.d.ts.map +1 -0
- package/script/helpers/prepareGraphTemporalSql.js +161 -0
- package/script/helpers/prepareGraphTraversal.d.ts +19 -0
- package/script/helpers/prepareGraphTraversal.d.ts.map +1 -0
- package/script/helpers/prepareGraphTraversal.js +87 -0
- package/script/helpers/prepareNumericFeatures.d.ts +41 -0
- package/script/helpers/prepareNumericFeatures.d.ts.map +1 -0
- package/script/helpers/prepareNumericFeatures.js +217 -0
- package/script/helpers/prettyDuration.d.ts +14 -8
- package/script/helpers/prettyDuration.d.ts.map +1 -1
- package/script/helpers/prettyDuration.js +14 -8
- package/script/helpers/printTable.d.ts +18 -13
- package/script/helpers/printTable.d.ts.map +1 -1
- package/script/helpers/printTable.js +18 -13
- package/script/helpers/publishPreparedColumns.d.ts +37 -0
- package/script/helpers/publishPreparedColumns.d.ts.map +1 -0
- package/script/helpers/publishPreparedColumns.js +119 -0
- package/script/helpers/queryDB.d.ts +24 -13
- package/script/helpers/queryDB.d.ts.map +1 -1
- package/script/helpers/queryDB.js +24 -13
- package/script/helpers/queueAsyncBarrier.d.ts +12 -7
- package/script/helpers/queueAsyncBarrier.d.ts.map +1 -1
- package/script/helpers/queueAsyncBarrier.js +12 -7
- package/script/helpers/queueGraphResult.d.ts +18 -0
- package/script/helpers/queueGraphResult.d.ts.map +1 -0
- package/script/helpers/queueGraphResult.js +45 -0
- package/script/helpers/quoteIdentifier.d.ts +4 -3
- package/script/helpers/quoteIdentifier.d.ts.map +1 -1
- package/script/helpers/quoteIdentifier.js +4 -3
- package/script/helpers/quoteQualifiedIdentifier.d.ts +6 -4
- package/script/helpers/quoteQualifiedIdentifier.d.ts.map +1 -1
- package/script/helpers/quoteQualifiedIdentifier.js +6 -4
- package/script/helpers/runQuery.d.ts.map +1 -1
- package/script/helpers/runQuery.js +17 -3
- package/script/helpers/selectFuzzyReplacements.d.ts +11 -0
- package/script/helpers/selectFuzzyReplacements.d.ts.map +1 -0
- package/script/helpers/selectFuzzyReplacements.js +127 -0
- package/script/helpers/stabilizeCosineVectors.d.ts +14 -0
- package/script/helpers/stabilizeCosineVectors.d.ts.map +1 -0
- package/script/helpers/stabilizeCosineVectors.js +40 -0
- package/script/helpers/stringToArray.d.ts +4 -3
- package/script/helpers/stringToArray.d.ts.map +1 -1
- package/script/helpers/stringToArray.js +4 -3
- package/script/helpers/updateColumnsWithJS.d.ts +12 -6
- package/script/helpers/updateColumnsWithJS.d.ts.map +1 -1
- package/script/helpers/updateColumnsWithJS.js +12 -6
- package/script/helpers/validateGraphRouteResultSchema.d.ts +4 -0
- package/script/helpers/validateGraphRouteResultSchema.d.ts.map +1 -0
- package/script/helpers/validateGraphRouteResultSchema.js +19 -0
- package/script/helpers/validateGraphTemporalEvents.d.ts +7 -0
- package/script/helpers/validateGraphTemporalEvents.d.ts.map +1 -0
- package/script/helpers/validateGraphTemporalEvents.js +53 -0
- package/script/helpers/validateNumericalAnalysis.d.ts +10 -6
- package/script/helpers/validateNumericalAnalysis.d.ts.map +1 -1
- package/script/helpers/validateNumericalAnalysis.js +10 -6
- package/script/helpers/validateVectorRowIds.d.ts +4 -0
- package/script/helpers/validateVectorRowIds.d.ts.map +1 -0
- package/script/helpers/validateVectorRowIds.js +19 -0
- package/script/helpers/vectorDistanceExpression.d.ts +6 -0
- package/script/helpers/vectorDistanceExpression.d.ts.map +1 -0
- package/script/helpers/vectorDistanceExpression.js +14 -0
- package/script/helpers/wrapString.d.ts +10 -7
- package/script/helpers/wrapString.d.ts.map +1 -1
- package/script/helpers/wrapString.js +10 -7
- package/script/methods/addId.d.ts +5 -0
- package/script/methods/addId.d.ts.map +1 -0
- package/script/methods/addId.js +44 -0
- package/script/methods/commonNeighbors.d.ts +10 -0
- package/script/methods/commonNeighbors.d.ts.map +1 -0
- package/script/methods/commonNeighbors.js +140 -0
- package/script/methods/connectedComponents.d.ts +9 -0
- package/script/methods/connectedComponents.d.ts.map +1 -0
- package/script/methods/connectedComponents.js +186 -0
- package/script/methods/degree.d.ts +9 -0
- package/script/methods/degree.d.ts.map +1 -0
- package/script/methods/degree.js +141 -0
- package/script/methods/distances.d.ts +12 -0
- package/script/methods/distances.d.ts.map +1 -0
- package/script/methods/distances.js +203 -0
- package/script/methods/findCycles.d.ts +12 -0
- package/script/methods/findCycles.d.ts.map +1 -0
- package/script/methods/findCycles.js +369 -0
- package/script/methods/fuzzyClean.d.ts.map +1 -1
- package/script/methods/fuzzyClean.js +17 -136
- package/script/methods/fuzzyJoin.js +70 -16
- package/script/methods/getTypes.d.ts +1 -1
- package/script/methods/hdbscan.d.ts +5 -0
- package/script/methods/hdbscan.d.ts.map +1 -0
- package/script/methods/hdbscan.js +214 -0
- package/script/methods/mahalanobis.d.ts +5 -0
- package/script/methods/mahalanobis.d.ts.map +1 -0
- package/script/methods/mahalanobis.js +98 -0
- package/script/methods/neighbors.d.ts +9 -0
- package/script/methods/neighbors.d.ts.map +1 -0
- package/script/methods/neighbors.js +120 -0
- package/script/methods/normalizeVector.d.ts +5 -0
- package/script/methods/normalizeVector.d.ts.map +1 -0
- package/script/methods/normalizeVector.js +138 -0
- package/script/methods/paths.d.ts +12 -0
- package/script/methods/paths.d.ts.map +1 -0
- package/script/methods/paths.js +326 -0
- package/script/methods/reachable.d.ts +11 -0
- package/script/methods/reachable.d.ts.map +1 -0
- package/script/methods/reachable.js +170 -0
- package/script/methods/rowToVector.d.ts +5 -0
- package/script/methods/rowToVector.d.ts.map +1 -0
- package/script/methods/rowToVector.js +83 -0
- package/script/methods/shortestPath.d.ts +12 -0
- package/script/methods/shortestPath.d.ts.map +1 -0
- package/script/methods/shortestPath.js +376 -0
- package/script/methods/topologicalSort.d.ts +7 -0
- package/script/methods/topologicalSort.d.ts.map +1 -0
- package/script/methods/topologicalSort.js +170 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { prepareGraphRouteEndpoints, prepareGraphRouteSql, validateGraphRouteInputs, } from "../helpers/prepareGraphRouteSql.js";
|
|
2
|
+
import graphRouteResultSchema from "../helpers/graphRouteResultSchema.js";
|
|
3
|
+
import graphRouteResultSelect from "../helpers/graphRouteResultSelect.js";
|
|
4
|
+
import prepareGraphTemporalSql, { prepareGraphTemporalOptions, } from "../helpers/prepareGraphTemporalSql.js";
|
|
5
|
+
import queueGraphResult from "../helpers/queueGraphResult.js";
|
|
6
|
+
import quoteIdentifier from "../helpers/quoteIdentifier.js";
|
|
7
|
+
import validateGraphTemporalEvents from "../helpers/validateGraphTemporalEvents.js";
|
|
8
|
+
export default function paths(simpleTable, sourceColumn, targetColumn, edgeId, start, end, options = {}) {
|
|
9
|
+
if (typeof sourceColumn !== "string") {
|
|
10
|
+
throw new TypeError("paths() sourceColumn must be a string.");
|
|
11
|
+
}
|
|
12
|
+
if (typeof targetColumn !== "string") {
|
|
13
|
+
throw new TypeError("paths() targetColumn must be a string.");
|
|
14
|
+
}
|
|
15
|
+
if (typeof edgeId !== "string") {
|
|
16
|
+
throw new TypeError("paths() edgeId must be a string.");
|
|
17
|
+
}
|
|
18
|
+
if (options === null || typeof options !== "object" || Array.isArray(options)) {
|
|
19
|
+
throw new TypeError("paths() options must be an object.");
|
|
20
|
+
}
|
|
21
|
+
if (options.direction !== undefined &&
|
|
22
|
+
!["outgoing", "incoming", "both"].includes(options.direction)) {
|
|
23
|
+
throw new TypeError('paths() options.direction must be "outgoing", "incoming", or "both".');
|
|
24
|
+
}
|
|
25
|
+
if (options.weight !== undefined && typeof options.weight !== "string") {
|
|
26
|
+
throw new TypeError("paths() options.weight must be a string.");
|
|
27
|
+
}
|
|
28
|
+
if (options.outputTable !== undefined &&
|
|
29
|
+
typeof options.outputTable !== "string" &&
|
|
30
|
+
typeof options.outputTable !== "boolean") {
|
|
31
|
+
throw new TypeError("paths() options.outputTable must be a string or boolean.");
|
|
32
|
+
}
|
|
33
|
+
const endpoints = prepareGraphRouteEndpoints(start, end, "paths()");
|
|
34
|
+
const direction = options.direction ?? "outgoing";
|
|
35
|
+
const temporalOptions = prepareGraphTemporalOptions(options, direction, "paths()");
|
|
36
|
+
options = structuredClone(options);
|
|
37
|
+
const parameters = {
|
|
38
|
+
sourceColumn,
|
|
39
|
+
targetColumn,
|
|
40
|
+
edgeId,
|
|
41
|
+
start,
|
|
42
|
+
end,
|
|
43
|
+
options,
|
|
44
|
+
};
|
|
45
|
+
return queueGraphResult(simpleTable, {
|
|
46
|
+
method: "paths()",
|
|
47
|
+
parameters,
|
|
48
|
+
outputTable: options.outputTable,
|
|
49
|
+
preflight: temporalOptions === undefined
|
|
50
|
+
? undefined
|
|
51
|
+
: (input) => validateGraphTemporalEvents(input, temporalOptions, "paths()", parameters),
|
|
52
|
+
values: (schema) => {
|
|
53
|
+
validateGraphRouteInputs(schema, sourceColumn, targetColumn, edgeId, endpoints, options.weight, "paths()");
|
|
54
|
+
const temporal = temporalOptions === undefined
|
|
55
|
+
? undefined
|
|
56
|
+
: prepareGraphTemporalSql(schema, temporalOptions, "paths()");
|
|
57
|
+
return temporal === undefined
|
|
58
|
+
? endpoints.values.values
|
|
59
|
+
: [temporal.gapParameter, ...endpoints.values.values];
|
|
60
|
+
},
|
|
61
|
+
buildSelect: (input, schema) => pathsSelect(input, schema, sourceColumn, targetColumn, edgeId, endpoints, direction, options.weight, temporalOptions),
|
|
62
|
+
outputSchema: (schema) => {
|
|
63
|
+
const validated = validateGraphRouteInputs(schema, sourceColumn, targetColumn, edgeId, endpoints, options.weight, "paths()");
|
|
64
|
+
if (temporalOptions !== undefined) {
|
|
65
|
+
prepareGraphTemporalSql(schema, temporalOptions, "paths()");
|
|
66
|
+
}
|
|
67
|
+
return graphRouteResultSchema(schema, validated.distanceType, "paths()");
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function pathsSelect(input, schema, source, target, edgeId, routeEndpoints, direction, weight, temporalOptions) {
|
|
72
|
+
const route = prepareGraphRouteSql(input, schema, source, target, edgeId, routeEndpoints, weight, "paths()");
|
|
73
|
+
const prepared = route.traversal;
|
|
74
|
+
if (temporalOptions !== undefined) {
|
|
75
|
+
const temporal = prepareGraphTemporalSql(schema, temporalOptions, "paths()");
|
|
76
|
+
return temporalPathsSelect(route, direction, temporal);
|
|
77
|
+
}
|
|
78
|
+
const distanceType = route.distanceType;
|
|
79
|
+
const q = quoteIdentifier;
|
|
80
|
+
const relations = prepared.relationNames([
|
|
81
|
+
"graph_route_endpoints",
|
|
82
|
+
"graph_edges",
|
|
83
|
+
"graph_nodes",
|
|
84
|
+
"graph_to_end",
|
|
85
|
+
"graph_routes",
|
|
86
|
+
"graph_complete_routes",
|
|
87
|
+
"graph_ranked_routes",
|
|
88
|
+
]);
|
|
89
|
+
const endpointRelation = relations.graph_route_endpoints;
|
|
90
|
+
const edgesRelation = relations.graph_edges;
|
|
91
|
+
const nodesRelation = relations.graph_nodes;
|
|
92
|
+
const toEndRelation = relations.graph_to_end;
|
|
93
|
+
const routesRelation = relations.graph_routes;
|
|
94
|
+
const completeRelation = relations.graph_complete_routes;
|
|
95
|
+
const rankedRelation = relations.graph_ranked_routes;
|
|
96
|
+
const edgeFromKey = `${q("edges")}.${q("__from_key")}`;
|
|
97
|
+
const edgeToKey = `${q("edges")}.${q("__to_key")}`;
|
|
98
|
+
const edgeTo = `${q("edges")}.${q("__to")}`;
|
|
99
|
+
const edgeCost = `${q("edges")}.${q("__weight")}`;
|
|
100
|
+
const candidateDistance = `CAST(${q("routes")}.${q("distance")} + ${edgeCost} AS ${distanceType})`;
|
|
101
|
+
return `WITH RECURSIVE ${endpointRelation}(
|
|
102
|
+
${q("start")}, ${q("end")}, ${q("__start_key")}, ${q("__end_key")}
|
|
103
|
+
) AS (
|
|
104
|
+
SELECT ${q("start")}, ${q("end")},
|
|
105
|
+
${prepared.key(q("start"))}, ${prepared.key(q("end"))}
|
|
106
|
+
FROM (SELECT ${route.endpointValue} AS ${q("start")},
|
|
107
|
+
${route.endpointValue} AS ${q("end")}) AS ${q("values")}
|
|
108
|
+
), ${edgesRelation} AS (
|
|
109
|
+
${prepared.edges(direction, [
|
|
110
|
+
`${route.typedEdgeId} AS ${q("__edge_id")}`,
|
|
111
|
+
`${route.edgeKey} AS ${q("__edge_key")}`,
|
|
112
|
+
`${route.edgeWeight} AS ${q("__weight")}`,
|
|
113
|
+
])}
|
|
114
|
+
), ${nodesRelation} AS (
|
|
115
|
+
SELECT ${q("__from_key")} AS ${q("__key")} FROM ${edgesRelation}
|
|
116
|
+
UNION
|
|
117
|
+
SELECT ${q("__to_key")} AS ${q("__key")} FROM ${edgesRelation}
|
|
118
|
+
), ${toEndRelation}(${q("__key")}) AS (
|
|
119
|
+
SELECT ${q("__end_key")}
|
|
120
|
+
FROM ${endpointRelation}
|
|
121
|
+
INNER JOIN ${nodesRelation}
|
|
122
|
+
ON ${q("__end_key")} = ${q("__key")}
|
|
123
|
+
UNION
|
|
124
|
+
SELECT ${edgeFromKey}
|
|
125
|
+
FROM ${toEndRelation} AS ${q("reached")}
|
|
126
|
+
INNER JOIN ${edgesRelation} AS ${q("edges")}
|
|
127
|
+
ON ${q("reached")}.${q("__key")} = ${edgeToKey}
|
|
128
|
+
), ${routesRelation}(
|
|
129
|
+
${q("node")}, ${q("__node_key")}, ${q("__visited")},
|
|
130
|
+
${q("__edge_keys")}, ${q("steps")}, ${q("distance")}
|
|
131
|
+
) AS (
|
|
132
|
+
SELECT ${q("start")}, ${q("__start_key")},
|
|
133
|
+
[${q("__start_key")}], CAST([] AS ${route.keyType}[]),
|
|
134
|
+
CAST([] AS ${route.stepType}[]), CAST(0 AS ${distanceType})
|
|
135
|
+
FROM ${endpointRelation}
|
|
136
|
+
INNER JOIN ${toEndRelation}
|
|
137
|
+
ON ${q("__start_key")} = ${q("__key")}
|
|
138
|
+
UNION ALL
|
|
139
|
+
SELECT ${edgeTo}, ${edgeToKey},
|
|
140
|
+
list_append(${q("routes")}.${q("__visited")}, ${edgeToKey}),
|
|
141
|
+
list_append(${q("routes")}.${q("__edge_keys")}, ${q("edges")}.${q("__edge_key")}),
|
|
142
|
+
list_append(${q("routes")}.${q("steps")}, struct_pack(
|
|
143
|
+
${q("edgeId")} := ${q("edges")}.${q("__edge_id")},
|
|
144
|
+
${q("source")} := ${q("edges")}.${q("__from")},
|
|
145
|
+
${q("target")} := ${edgeTo},
|
|
146
|
+
${q("weight")} := ${edgeCost},
|
|
147
|
+
${q("distance")} := ${candidateDistance}
|
|
148
|
+
)), ${candidateDistance}
|
|
149
|
+
FROM ${routesRelation} AS ${q("routes")}
|
|
150
|
+
INNER JOIN ${edgesRelation} AS ${q("edges")}
|
|
151
|
+
ON ${q("routes")}.${q("__node_key")} = ${edgeFromKey}
|
|
152
|
+
INNER JOIN ${toEndRelation} AS ${q("can_reach_end")}
|
|
153
|
+
ON ${edgeToKey} = ${q("can_reach_end")}.${q("__key")}
|
|
154
|
+
CROSS JOIN ${endpointRelation}
|
|
155
|
+
WHERE ${q("routes")}.${q("__node_key")} <> ${q("__end_key")}
|
|
156
|
+
AND NOT list_contains(${q("routes")}.${q("__visited")}, ${edgeToKey})
|
|
157
|
+
), ${completeRelation} AS (
|
|
158
|
+
SELECT ${q("__edge_keys")}, ${q("steps")}
|
|
159
|
+
FROM ${routesRelation}
|
|
160
|
+
CROSS JOIN ${endpointRelation}
|
|
161
|
+
WHERE ${q("__node_key")} = ${q("__end_key")}
|
|
162
|
+
), ${rankedRelation} AS (
|
|
163
|
+
SELECT CAST(row_number() OVER (ORDER BY ${q("__edge_keys")}) - 1 AS BIGINT) AS ${q("pathId")},
|
|
164
|
+
${q("steps")}
|
|
165
|
+
FROM ${completeRelation}
|
|
166
|
+
)
|
|
167
|
+
${graphRouteResultSelect(rankedRelation, route.input, route.edgeIdColumn)}`;
|
|
168
|
+
}
|
|
169
|
+
function temporalPathsSelect(route, direction, temporal) {
|
|
170
|
+
const prepared = route.traversal;
|
|
171
|
+
const distanceType = route.distanceType;
|
|
172
|
+
const q = quoteIdentifier;
|
|
173
|
+
const relations = prepared.relationNames([
|
|
174
|
+
"graph_route_endpoints",
|
|
175
|
+
"graph_temporal_settings",
|
|
176
|
+
"graph_event_rows",
|
|
177
|
+
"graph_edges",
|
|
178
|
+
"graph_nodes",
|
|
179
|
+
"graph_to_end",
|
|
180
|
+
"graph_routes",
|
|
181
|
+
"graph_complete_routes",
|
|
182
|
+
"graph_ranked_routes",
|
|
183
|
+
]);
|
|
184
|
+
const endpointRelation = relations.graph_route_endpoints;
|
|
185
|
+
const settingsRelation = relations.graph_temporal_settings;
|
|
186
|
+
const eventRowsRelation = relations.graph_event_rows;
|
|
187
|
+
const edgesRelation = relations.graph_edges;
|
|
188
|
+
const nodesRelation = relations.graph_nodes;
|
|
189
|
+
const toEndRelation = relations.graph_to_end;
|
|
190
|
+
const routesRelation = relations.graph_routes;
|
|
191
|
+
const completeRelation = relations.graph_complete_routes;
|
|
192
|
+
const rankedRelation = relations.graph_ranked_routes;
|
|
193
|
+
const edgeFromKey = `${q("edges")}.${q("__from_key")}`;
|
|
194
|
+
const edgeToKey = `${q("edges")}.${q("__to_key")}`;
|
|
195
|
+
const edgeTo = `${q("edges")}.${q("__to")}`;
|
|
196
|
+
const edgeCost = `${q("edges")}.${q("__weight")}`;
|
|
197
|
+
const edgeKey = `${q("edges")}.${q("__edge_key")}`;
|
|
198
|
+
const candidateDistance = `CAST(${q("routes")}.${q("distance")} + ${edgeCost} AS ${distanceType})`;
|
|
199
|
+
const gap = `${q("settings")}.${q("__gap")}`;
|
|
200
|
+
const step = (distance) => `struct_pack(
|
|
201
|
+
${q("edgeId")} := ${q("edges")}.${q("__edge_id")},
|
|
202
|
+
${q("source")} := ${q("edges")}.${q("__from")},
|
|
203
|
+
${q("target")} := ${edgeTo},
|
|
204
|
+
${q("weight")} := ${edgeCost},
|
|
205
|
+
${q("distance")} := ${distance}
|
|
206
|
+
)`;
|
|
207
|
+
return `WITH RECURSIVE ${settingsRelation} AS MATERIALIZED (
|
|
208
|
+
SELECT CAST(? AS HUGEINT) AS ${q("__gap")}
|
|
209
|
+
), ${endpointRelation}(
|
|
210
|
+
${q("start")}, ${q("end")}, ${q("__start_key")}, ${q("__end_key")}
|
|
211
|
+
) AS (
|
|
212
|
+
SELECT ${q("start")}, ${q("end")},
|
|
213
|
+
${prepared.key(q("start"))}, ${prepared.key(q("end"))}
|
|
214
|
+
FROM (SELECT ${route.endpointValue} AS ${q("start")},
|
|
215
|
+
${route.endpointValue} AS ${q("end")}) AS ${q("values")}
|
|
216
|
+
), ${eventRowsRelation} AS MATERIALIZED (
|
|
217
|
+
${prepared.edges(direction, [
|
|
218
|
+
`${route.typedEdgeId} AS ${q("__edge_id")}`,
|
|
219
|
+
`${route.edgeKey} AS ${q("__edge_key")}`,
|
|
220
|
+
`${route.edgeWeight} AS ${q("__weight")}`,
|
|
221
|
+
...temporal.eventSelections("edges"),
|
|
222
|
+
])}
|
|
223
|
+
), ${edgesRelation} AS MATERIALIZED (
|
|
224
|
+
SELECT *
|
|
225
|
+
FROM ${eventRowsRelation} AS ${q("events")}
|
|
226
|
+
WHERE ${temporal.eventValidity("events")}
|
|
227
|
+
), ${nodesRelation} AS (
|
|
228
|
+
SELECT ${q("__from_key")} AS ${q("__key")} FROM ${edgesRelation}
|
|
229
|
+
UNION
|
|
230
|
+
SELECT ${q("__to_key")} AS ${q("__key")} FROM ${edgesRelation}
|
|
231
|
+
), ${toEndRelation}(${q("__key")}) AS (
|
|
232
|
+
SELECT ${q("__end_key")}
|
|
233
|
+
FROM ${endpointRelation}
|
|
234
|
+
INNER JOIN ${nodesRelation}
|
|
235
|
+
ON ${q("__end_key")} = ${q("__key")}
|
|
236
|
+
UNION
|
|
237
|
+
SELECT ${edgeFromKey}
|
|
238
|
+
FROM ${toEndRelation} AS ${q("reached")}
|
|
239
|
+
INNER JOIN ${edgesRelation} AS ${q("edges")}
|
|
240
|
+
ON ${q("reached")}.${q("__key")} = ${edgeToKey}
|
|
241
|
+
), ${routesRelation}(
|
|
242
|
+
${q("node")}, ${q("__node_key")}, ${q("__visited")},
|
|
243
|
+
${q("__edge_keys")}, ${q("steps")}, ${q("distance")},
|
|
244
|
+
${q("__event_id")}, ${q("__event_start")}, ${q("__event_end")}
|
|
245
|
+
) AS (
|
|
246
|
+
SELECT ${edgeTo}, ${edgeToKey},
|
|
247
|
+
[${q("__start_key")}, ${edgeToKey}], [${edgeKey}],
|
|
248
|
+
[${step(edgeCost)}], ${edgeCost},
|
|
249
|
+
${q("edges")}.${q("__event_id")},
|
|
250
|
+
${q("edges")}.${q("__event_start")},
|
|
251
|
+
${q("edges")}.${q("__event_end")}
|
|
252
|
+
FROM ${endpointRelation}
|
|
253
|
+
INNER JOIN ${edgesRelation} AS ${q("edges")}
|
|
254
|
+
ON ${q("__start_key")} = ${edgeFromKey}
|
|
255
|
+
INNER JOIN ${toEndRelation} AS ${q("can_reach_end")}
|
|
256
|
+
ON ${edgeToKey} = ${q("can_reach_end")}.${q("__key")}
|
|
257
|
+
WHERE ${q("__start_key")} <> ${edgeToKey}
|
|
258
|
+
UNION ALL
|
|
259
|
+
SELECT ${edgeTo}, ${edgeToKey},
|
|
260
|
+
list_append(${q("routes")}.${q("__visited")}, ${edgeToKey}),
|
|
261
|
+
list_append(${q("routes")}.${q("__edge_keys")}, ${edgeKey}),
|
|
262
|
+
list_append(${q("routes")}.${q("steps")}, ${step(candidateDistance)}),
|
|
263
|
+
${candidateDistance}, ${q("edges")}.${q("__event_id")},
|
|
264
|
+
${q("edges")}.${q("__event_start")},
|
|
265
|
+
${q("edges")}.${q("__event_end")}
|
|
266
|
+
FROM ${routesRelation} AS ${q("routes")}
|
|
267
|
+
INNER JOIN ${edgesRelation} AS ${q("edges")}
|
|
268
|
+
ON ${q("routes")}.${q("__node_key")} = ${edgeFromKey}
|
|
269
|
+
INNER JOIN ${toEndRelation} AS ${q("can_reach_end")}
|
|
270
|
+
ON ${edgeToKey} = ${q("can_reach_end")}.${q("__key")}
|
|
271
|
+
CROSS JOIN ${endpointRelation}
|
|
272
|
+
CROSS JOIN ${settingsRelation} AS ${q("settings")}
|
|
273
|
+
WHERE ${q("routes")}.${q("__node_key")} <> ${q("__end_key")}
|
|
274
|
+
AND NOT list_contains(${q("routes")}.${q("__visited")}, ${edgeToKey})
|
|
275
|
+
AND ${temporal.transition("routes", "edges", direction, gap)}
|
|
276
|
+
), ${completeRelation} AS (
|
|
277
|
+
SELECT ${q("__edge_keys")}, ${q("steps")}
|
|
278
|
+
FROM ${routesRelation}
|
|
279
|
+
CROSS JOIN ${endpointRelation}
|
|
280
|
+
WHERE ${q("__node_key")} = ${q("__end_key")}
|
|
281
|
+
), ${rankedRelation} AS (
|
|
282
|
+
SELECT CAST(row_number() OVER (ORDER BY ${q("__edge_keys")}) - 1 AS BIGINT)
|
|
283
|
+
AS ${q("pathId")}, ${q("steps")}
|
|
284
|
+
FROM ${completeRelation}
|
|
285
|
+
)
|
|
286
|
+
${graphRouteResultSelect(rankedRelation, route.input, route.edgeIdColumn)}`;
|
|
287
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type SimpleTable from "../class/SimpleTable.js";
|
|
2
|
+
import { type GraphTemporalOptions } from "../helpers/prepareGraphTemporalSql.js";
|
|
3
|
+
import { type GraphId } from "../helpers/prepareGraphStarts.js";
|
|
4
|
+
import { type GraphDirection } from "../helpers/prepareGraphTraversal.js";
|
|
5
|
+
type ReachableOptions = GraphTemporalOptions & {
|
|
6
|
+
direction?: GraphDirection;
|
|
7
|
+
outputTable?: string | boolean;
|
|
8
|
+
};
|
|
9
|
+
export default function reachable(simpleTable: SimpleTable, sourceColumn: string, targetColumn: string, startNodes: GraphId | GraphId[], options?: ReachableOptions): SimpleTable;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=reachable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reachable.d.ts","sourceRoot":"","sources":["../../src/methods/reachable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAGvD,OAAgC,EAC9B,KAAK,oBAAoB,EAG1B,MAAM,uCAAuC,CAAC;AAC/C,OAA2B,EACzB,KAAK,OAAO,EAEb,MAAM,kCAAkC,CAAC;AAC1C,OAA8B,EAC5B,KAAK,cAAc,EAEpB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,gBAAgB,GAAG,oBAAoB,GAAG;IAC7C,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,OAAO,GAAG,OAAO,EAAE,EAC/B,OAAO,GAAE,gBAAqB,GAC7B,WAAW,CAkGb"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import buildGraphTemporalReachabilitySql from "../helpers/buildGraphTemporalReachabilitySql.js";
|
|
2
|
+
import prepareGraphTemporalSql, { prepareGraphTemporalOptions, } from "../helpers/prepareGraphTemporalSql.js";
|
|
3
|
+
import prepareGraphStarts from "../helpers/prepareGraphStarts.js";
|
|
4
|
+
import prepareGraphTraversal, { validateGraphStarts, } from "../helpers/prepareGraphTraversal.js";
|
|
5
|
+
import queueGraphResult from "../helpers/queueGraphResult.js";
|
|
6
|
+
import quoteIdentifier from "../helpers/quoteIdentifier.js";
|
|
7
|
+
import validateGraphTemporalEvents from "../helpers/validateGraphTemporalEvents.js";
|
|
8
|
+
export default function reachable(simpleTable, sourceColumn, targetColumn, startNodes, options = {}) {
|
|
9
|
+
if (typeof sourceColumn !== "string") {
|
|
10
|
+
throw new TypeError("reachable() sourceColumn must be a string.");
|
|
11
|
+
}
|
|
12
|
+
if (typeof targetColumn !== "string") {
|
|
13
|
+
throw new TypeError("reachable() targetColumn must be a string.");
|
|
14
|
+
}
|
|
15
|
+
if (options === null || typeof options !== "object" || Array.isArray(options)) {
|
|
16
|
+
throw new TypeError("reachable() options must be an object.");
|
|
17
|
+
}
|
|
18
|
+
if (options.direction !== undefined &&
|
|
19
|
+
!["outgoing", "incoming", "both"].includes(options.direction)) {
|
|
20
|
+
throw new TypeError('reachable() options.direction must be "outgoing", "incoming", or "both".');
|
|
21
|
+
}
|
|
22
|
+
if (options.outputTable !== undefined &&
|
|
23
|
+
typeof options.outputTable !== "string" &&
|
|
24
|
+
typeof options.outputTable !== "boolean") {
|
|
25
|
+
throw new TypeError("reachable() options.outputTable must be a string or boolean.");
|
|
26
|
+
}
|
|
27
|
+
const preparedStarts = prepareGraphStarts(startNodes, "reachable()", "startNodes");
|
|
28
|
+
const direction = options.direction ?? "outgoing";
|
|
29
|
+
const temporalOptions = prepareGraphTemporalOptions(options, direction, "reachable()");
|
|
30
|
+
options = structuredClone(options);
|
|
31
|
+
const parameters = {
|
|
32
|
+
sourceColumn,
|
|
33
|
+
targetColumn,
|
|
34
|
+
startNodes: structuredClone(startNodes),
|
|
35
|
+
options,
|
|
36
|
+
};
|
|
37
|
+
return queueGraphResult(simpleTable, {
|
|
38
|
+
method: "reachable()",
|
|
39
|
+
parameters,
|
|
40
|
+
outputTable: options.outputTable,
|
|
41
|
+
preflight: temporalOptions === undefined
|
|
42
|
+
? undefined
|
|
43
|
+
: (input) => validateGraphTemporalEvents(input, temporalOptions, "reachable()", parameters),
|
|
44
|
+
values: (schema) => {
|
|
45
|
+
const { temporal } = validateInputs(schema, sourceColumn, targetColumn, preparedStarts, temporalOptions);
|
|
46
|
+
return temporal === undefined
|
|
47
|
+
? preparedStarts.values
|
|
48
|
+
: [temporal.gapParameter, ...preparedStarts.values];
|
|
49
|
+
},
|
|
50
|
+
buildSelect: (input, schema) => reachableSelect(input, schema, sourceColumn, targetColumn, preparedStarts, direction, temporalOptions),
|
|
51
|
+
outputSchema: (schema) => {
|
|
52
|
+
const { endpoints } = validateInputs(schema, sourceColumn, targetColumn, preparedStarts, temporalOptions);
|
|
53
|
+
return {
|
|
54
|
+
start: endpoints.idType,
|
|
55
|
+
node: endpoints.idType,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function validateInputs(schema, source, target, starts, temporalOptions) {
|
|
61
|
+
const endpoints = validateGraphStarts(schema, source, target, starts, "reachable()", "startNodes");
|
|
62
|
+
const temporal = temporalOptions === undefined
|
|
63
|
+
? undefined
|
|
64
|
+
: prepareGraphTemporalSql(schema, temporalOptions, "reachable()");
|
|
65
|
+
return { endpoints, temporal };
|
|
66
|
+
}
|
|
67
|
+
function reachableSelect(input, schema, source, target, starts, direction, temporalOptions) {
|
|
68
|
+
const prepared = prepareGraphTraversal(input, schema, source, target, starts, "reachable()", "startNodes");
|
|
69
|
+
if (temporalOptions !== undefined) {
|
|
70
|
+
const temporal = prepareGraphTemporalSql(schema, temporalOptions, "reachable()");
|
|
71
|
+
return temporalReachableSelect(prepared, direction, temporal);
|
|
72
|
+
}
|
|
73
|
+
const relations = prepared.relationNames([
|
|
74
|
+
"graph_start_values",
|
|
75
|
+
"graph_starts",
|
|
76
|
+
"graph_edges",
|
|
77
|
+
"graph_reachable",
|
|
78
|
+
]);
|
|
79
|
+
const startValuesRelation = relations.graph_start_values;
|
|
80
|
+
const startsRelation = relations.graph_starts;
|
|
81
|
+
const edgesRelation = relations.graph_edges;
|
|
82
|
+
const reachableRelation = relations.graph_reachable;
|
|
83
|
+
const start = `${quoteIdentifier("starts")}.${quoteIdentifier("start")}`;
|
|
84
|
+
const startKey = `${quoteIdentifier("starts")}.${quoteIdentifier("__key")}`;
|
|
85
|
+
const reachedStart = `${quoteIdentifier("reached")}.${quoteIdentifier("start")}`;
|
|
86
|
+
const reachedStartKey = `${quoteIdentifier("reached")}.${quoteIdentifier("__start_key")}`;
|
|
87
|
+
const edgeTo = `${quoteIdentifier("edges")}.${quoteIdentifier("__to")}`;
|
|
88
|
+
const edgeToKey = `${quoteIdentifier("edges")}.${quoteIdentifier("__to_key")}`;
|
|
89
|
+
const edgeFromKey = `${quoteIdentifier("edges")}.${quoteIdentifier("__from_key")}`;
|
|
90
|
+
const reachedNodeKey = `${quoteIdentifier("reached")}.${quoteIdentifier("__node_key")}`;
|
|
91
|
+
return `WITH RECURSIVE ${startValuesRelation}(${quoteIdentifier("start")}) AS (
|
|
92
|
+
VALUES ${prepared.startValues}
|
|
93
|
+
), ${startsRelation} AS (
|
|
94
|
+
SELECT ${quoteIdentifier("start")},
|
|
95
|
+
${prepared.key(quoteIdentifier("start"))} AS ${quoteIdentifier("__key")}
|
|
96
|
+
FROM ${startValuesRelation}
|
|
97
|
+
), ${edgesRelation} AS (
|
|
98
|
+
${prepared.edges(direction)}
|
|
99
|
+
), ${reachableRelation}(
|
|
100
|
+
${quoteIdentifier("start")}, ${quoteIdentifier("node")},
|
|
101
|
+
${quoteIdentifier("__start_key")}, ${quoteIdentifier("__node_key")}
|
|
102
|
+
) AS (
|
|
103
|
+
SELECT ${start}, ${edgeTo}, ${startKey}, ${edgeToKey}
|
|
104
|
+
FROM ${startsRelation} AS ${quoteIdentifier("starts")}
|
|
105
|
+
INNER JOIN ${edgesRelation} AS ${quoteIdentifier("edges")}
|
|
106
|
+
ON ${startKey} = ${edgeFromKey}
|
|
107
|
+
UNION
|
|
108
|
+
SELECT ${reachedStart}, ${edgeTo}, ${reachedStartKey}, ${edgeToKey}
|
|
109
|
+
FROM ${reachableRelation} AS ${quoteIdentifier("reached")}
|
|
110
|
+
INNER JOIN ${edgesRelation} AS ${quoteIdentifier("edges")}
|
|
111
|
+
ON ${reachedNodeKey} = ${edgeFromKey}
|
|
112
|
+
)
|
|
113
|
+
SELECT ${quoteIdentifier("start")}, ${quoteIdentifier("node")}
|
|
114
|
+
FROM ${reachableRelation}
|
|
115
|
+
ORDER BY ${quoteIdentifier("__start_key")}, ${quoteIdentifier("__node_key")}`;
|
|
116
|
+
}
|
|
117
|
+
function temporalReachableSelect(prepared, direction, temporal) {
|
|
118
|
+
const q = quoteIdentifier;
|
|
119
|
+
const startsSelect = `SELECT ${q("start")},
|
|
120
|
+
${prepared.key(q("start"))} AS ${q("__key")}
|
|
121
|
+
FROM (VALUES ${prepared.startValues}) AS ${q("start_values")}(${q("start")})`;
|
|
122
|
+
const reachability = buildGraphTemporalReachabilitySql(prepared, startsSelect, direction, temporal);
|
|
123
|
+
return `${reachability.withClause}
|
|
124
|
+
SELECT ${q("start")}, ${q("node")}
|
|
125
|
+
FROM (
|
|
126
|
+
SELECT DISTINCT ${q("start")}, ${q("node")},
|
|
127
|
+
${q("__start_key")}, ${q("__node_key")}
|
|
128
|
+
FROM ${reachability.reachableRelation}
|
|
129
|
+
) AS ${q("reachable_nodes")}
|
|
130
|
+
ORDER BY ${q("__start_key")}, ${q("__node_key")}`;
|
|
131
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rowToVector.d.ts","sourceRoot":"","sources":["../../src/methods/rowToVector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAOvD,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;CAAO,QAyD5C"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import foldIdentifier from "../helpers/foldIdentifier.js";
|
|
2
|
+
import { isNumericScalarType } from "../helpers/prepareNumericFeatures.js";
|
|
3
|
+
import queueOp from "../helpers/queueOp.js";
|
|
4
|
+
import quoteIdentifier from "../helpers/quoteIdentifier.js";
|
|
5
|
+
export default function rowToVector(table, columns, newColumn, options = {}) {
|
|
6
|
+
if (columns.length === 0) {
|
|
7
|
+
throw new Error("rowToVector() requires at least one numeric scalar input column.");
|
|
8
|
+
}
|
|
9
|
+
const duplicate = findDuplicate(columns);
|
|
10
|
+
if (duplicate !== undefined) {
|
|
11
|
+
throw new Error(`rowToVector() received duplicate input column ${quoteIdentifier(duplicate)}. Each input column must be listed once.`);
|
|
12
|
+
}
|
|
13
|
+
if (options.type !== undefined && !["float", "double"].includes(options.type)) {
|
|
14
|
+
throw new Error('rowToVector() options.type must be "float" or "double".');
|
|
15
|
+
}
|
|
16
|
+
columns = [...columns];
|
|
17
|
+
options = structuredClone(options);
|
|
18
|
+
queueOp(table, {
|
|
19
|
+
kind: "fusable",
|
|
20
|
+
method: "rowToVector()",
|
|
21
|
+
parameters: { columns, newColumn, options },
|
|
22
|
+
needsSchema: true,
|
|
23
|
+
outputSchema: (schema) => ({
|
|
24
|
+
...schema,
|
|
25
|
+
[newColumn]: `${resolveElementType(schema, columns, newColumn, options)}[${columns.length}]`,
|
|
26
|
+
}),
|
|
27
|
+
buildSelect: (input, schema) => {
|
|
28
|
+
const elementType = resolveElementType(schema, columns, newColumn, options);
|
|
29
|
+
const resolved = resolveColumns(schema, columns);
|
|
30
|
+
return `SELECT *, [${resolved.map((column) => {
|
|
31
|
+
const value = quoteIdentifier(column);
|
|
32
|
+
// DuckDB does not implement a direct BIGNUM-to-FLOAT cast.
|
|
33
|
+
const convertible = schema[column] === "BIGNUM" && elementType === "FLOAT"
|
|
34
|
+
? `${value}::VARCHAR`
|
|
35
|
+
: value;
|
|
36
|
+
return `${convertible}::${elementType}`;
|
|
37
|
+
}).join(", ")}]::${elementType}[${columns.length}] AS ${quoteIdentifier(newColumn)} FROM ${input}`;
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function resolveElementType(schema, columns, newColumn, options) {
|
|
42
|
+
const existingOutput = Object.keys(schema).find((column) => foldIdentifier(column) === foldIdentifier(newColumn));
|
|
43
|
+
if (existingOutput !== undefined) {
|
|
44
|
+
throw new Error(`rowToVector() the column ${quoteIdentifier(newColumn)} already exists. Remove it first or choose a different name for the new column.`);
|
|
45
|
+
}
|
|
46
|
+
const resolved = resolveColumns(schema, columns);
|
|
47
|
+
const nonNumeric = resolved.filter((column) => !isNumericScalarType(schema[column]));
|
|
48
|
+
if (nonNumeric.length > 0) {
|
|
49
|
+
throw new Error(`rowToVector() requires numeric scalar input columns. The following columns are not numeric: ${nonNumeric.map((column) => `${quoteIdentifier(column)} (${schema[column]})`).join(", ")}. Convert them to numeric types first.`);
|
|
50
|
+
}
|
|
51
|
+
if (options.type !== undefined)
|
|
52
|
+
return options.type.toUpperCase();
|
|
53
|
+
const inputTypes = resolved.map((column) => schema[column]);
|
|
54
|
+
if (new Set(inputTypes).size !== 1) {
|
|
55
|
+
throw new Error(`rowToVector() cannot infer one vector element type from columns with different types: ${resolved.map((column) => `${quoteIdentifier(column)} (${schema[column]})`).join(", ")}. Set options.type to "float" or "double".`);
|
|
56
|
+
}
|
|
57
|
+
return inputTypes[0];
|
|
58
|
+
}
|
|
59
|
+
function resolveColumns(schema, columns) {
|
|
60
|
+
const available = Object.keys(schema);
|
|
61
|
+
const resolved = columns.map((requested) => available.find((column) => foldIdentifier(column) === foldIdentifier(requested)));
|
|
62
|
+
const missing = columns.filter((_, index) => resolved[index] === undefined);
|
|
63
|
+
if (missing.length > 0) {
|
|
64
|
+
throw new Error(`rowToVector() the column${missing.length > 1 ? "s" : ""} ${missing.map(quoteIdentifier).join(", ")} ${missing.length > 1 ? "do" : "does"} not exist. Check for typos, or load the data first.`);
|
|
65
|
+
}
|
|
66
|
+
return resolved;
|
|
67
|
+
}
|
|
68
|
+
function findDuplicate(columns) {
|
|
69
|
+
const seen = new Set();
|
|
70
|
+
for (const column of columns) {
|
|
71
|
+
const folded = foldIdentifier(column);
|
|
72
|
+
if (seen.has(folded))
|
|
73
|
+
return column;
|
|
74
|
+
seen.add(folded);
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type SimpleTable from "../class/SimpleTable.js";
|
|
2
|
+
import type { GraphId } from "../helpers/prepareGraphStarts.js";
|
|
3
|
+
import { type GraphTemporalOptions } from "../helpers/prepareGraphTemporalSql.js";
|
|
4
|
+
import type { GraphDirection } from "../helpers/prepareGraphTraversal.js";
|
|
5
|
+
type ShortestPathOptions = GraphTemporalOptions & {
|
|
6
|
+
direction?: GraphDirection;
|
|
7
|
+
outputTable?: string | boolean;
|
|
8
|
+
weight?: string;
|
|
9
|
+
};
|
|
10
|
+
export default function shortestPath(simpleTable: SimpleTable, sourceColumn: string, targetColumn: string, edgeId: string, start: GraphId, end: GraphId, options?: ShortestPathOptions): SimpleTable;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=shortestPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortestPath.d.ts","sourceRoot":"","sources":["../../src/methods/shortestPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAGvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAShE,OAAgC,EAC9B,KAAK,oBAAoB,EAG1B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAK1E,KAAK,mBAAmB,GAAG,oBAAoB,GAAG;IAChD,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE,mBAAwB,GAChC,WAAW,CAmHb"}
|