@ladybugmem/icebug 0.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/README.md +14 -0
- package/binding.gyp +54 -0
- package/build/Release/.deps/Release/icebug.node.d +1 -0
- package/build/Release/.deps/Release/obj.target/icebug/src/addon.o.d +291 -0
- package/build/Release/icebug.node +0 -0
- package/build/Release/obj.target/icebug/src/addon.o +0 -0
- package/lib/index.d.ts +361 -0
- package/lib/index.js +102 -0
- package/package.json +42 -0
- package/src/addon.cpp +1253 -0
- package/vendor/include/networkit/GlobalState.hpp +86 -0
- package/vendor/include/networkit/Globals.hpp +41 -0
- package/vendor/include/networkit/algebraic/AlgebraicGlobals.hpp +27 -0
- package/vendor/include/networkit/algebraic/CSRGeneralMatrix.hpp +1292 -0
- package/vendor/include/networkit/algebraic/CSRMatrix.hpp +11 -0
- package/vendor/include/networkit/algebraic/DenseMatrix.hpp +537 -0
- package/vendor/include/networkit/algebraic/DynamicMatrix.hpp +514 -0
- package/vendor/include/networkit/algebraic/GraphBLAS.hpp +323 -0
- package/vendor/include/networkit/algebraic/MatrixTools.hpp +156 -0
- package/vendor/include/networkit/algebraic/Semirings.hpp +171 -0
- package/vendor/include/networkit/algebraic/SparseAccumulator.hpp +111 -0
- package/vendor/include/networkit/algebraic/Vector.hpp +371 -0
- package/vendor/include/networkit/algebraic/algorithms/AlgebraicBFS.hpp +72 -0
- package/vendor/include/networkit/algebraic/algorithms/AlgebraicBellmanFord.hpp +88 -0
- package/vendor/include/networkit/algebraic/algorithms/AlgebraicMatchingCoarsening.hpp +96 -0
- package/vendor/include/networkit/algebraic/algorithms/AlgebraicPageRank.hpp +145 -0
- package/vendor/include/networkit/algebraic/algorithms/AlgebraicSpanningEdgeCentrality.hpp +122 -0
- package/vendor/include/networkit/algebraic/algorithms/AlgebraicTriangleCounting.hpp +76 -0
- package/vendor/include/networkit/auxiliary/AlignedAllocator.hpp +113 -0
- package/vendor/include/networkit/auxiliary/ArrayTools.hpp +85 -0
- package/vendor/include/networkit/auxiliary/BloomFilter.hpp +70 -0
- package/vendor/include/networkit/auxiliary/BucketPQ.hpp +142 -0
- package/vendor/include/networkit/auxiliary/Enforce.hpp +117 -0
- package/vendor/include/networkit/auxiliary/FunctionTraits.hpp +74 -0
- package/vendor/include/networkit/auxiliary/HashUtils.hpp +28 -0
- package/vendor/include/networkit/auxiliary/IncrementalUniformRandomSelector.hpp +52 -0
- package/vendor/include/networkit/auxiliary/Log.hpp +119 -0
- package/vendor/include/networkit/auxiliary/MissingMath.hpp +48 -0
- package/vendor/include/networkit/auxiliary/Multiprecision.hpp +17 -0
- package/vendor/include/networkit/auxiliary/NumberParsing.hpp +307 -0
- package/vendor/include/networkit/auxiliary/NumericTools.hpp +57 -0
- package/vendor/include/networkit/auxiliary/Parallel.hpp +56 -0
- package/vendor/include/networkit/auxiliary/Parallelism.hpp +33 -0
- package/vendor/include/networkit/auxiliary/PrioQueue.hpp +252 -0
- package/vendor/include/networkit/auxiliary/Random.hpp +122 -0
- package/vendor/include/networkit/auxiliary/SetIntersector.hpp +72 -0
- package/vendor/include/networkit/auxiliary/SignalHandling.hpp +39 -0
- package/vendor/include/networkit/auxiliary/SortedList.hpp +128 -0
- package/vendor/include/networkit/auxiliary/SparseVector.hpp +215 -0
- package/vendor/include/networkit/auxiliary/SpinLock.hpp +23 -0
- package/vendor/include/networkit/auxiliary/StringBuilder.hpp +322 -0
- package/vendor/include/networkit/auxiliary/StringTools.hpp +76 -0
- package/vendor/include/networkit/auxiliary/TemplateUtils.hpp +76 -0
- package/vendor/include/networkit/auxiliary/Timer.hpp +145 -0
- package/vendor/include/networkit/auxiliary/VectorComparator.hpp +32 -0
- package/vendor/include/networkit/base/Algorithm.hpp +41 -0
- package/vendor/include/networkit/base/DynAlgorithm.hpp +31 -0
- package/vendor/include/networkit/centrality/ApproxBetweenness.hpp +62 -0
- package/vendor/include/networkit/centrality/ApproxCloseness.hpp +136 -0
- package/vendor/include/networkit/centrality/ApproxElectricalCloseness.hpp +156 -0
- package/vendor/include/networkit/centrality/ApproxGroupBetweenness.hpp +124 -0
- package/vendor/include/networkit/centrality/ApproxSpanningEdge.hpp +84 -0
- package/vendor/include/networkit/centrality/Betweenness.hpp +47 -0
- package/vendor/include/networkit/centrality/Centrality.hpp +98 -0
- package/vendor/include/networkit/centrality/Closeness.hpp +107 -0
- package/vendor/include/networkit/centrality/ComplexPaths.hpp +113 -0
- package/vendor/include/networkit/centrality/CoreDecomposition.hpp +161 -0
- package/vendor/include/networkit/centrality/DegreeCentrality.hpp +55 -0
- package/vendor/include/networkit/centrality/DynApproxBetweenness.hpp +95 -0
- package/vendor/include/networkit/centrality/DynBetweenness.hpp +99 -0
- package/vendor/include/networkit/centrality/DynBetweennessOneNode.hpp +98 -0
- package/vendor/include/networkit/centrality/DynKatzCentrality.hpp +115 -0
- package/vendor/include/networkit/centrality/DynTopHarmonicCloseness.hpp +223 -0
- package/vendor/include/networkit/centrality/EigenvectorCentrality.hpp +41 -0
- package/vendor/include/networkit/centrality/EstimateBetweenness.hpp +51 -0
- package/vendor/include/networkit/centrality/ForestCentrality.hpp +112 -0
- package/vendor/include/networkit/centrality/GedWalk.hpp +225 -0
- package/vendor/include/networkit/centrality/GroupCloseness.hpp +115 -0
- package/vendor/include/networkit/centrality/GroupClosenessGrowShrink.hpp +78 -0
- package/vendor/include/networkit/centrality/GroupClosenessLocalSearch.hpp +77 -0
- package/vendor/include/networkit/centrality/GroupClosenessLocalSwaps.hpp +106 -0
- package/vendor/include/networkit/centrality/GroupDegree.hpp +155 -0
- package/vendor/include/networkit/centrality/GroupHarmonicCloseness.hpp +83 -0
- package/vendor/include/networkit/centrality/HarmonicCloseness.hpp +48 -0
- package/vendor/include/networkit/centrality/KPathCentrality.hpp +52 -0
- package/vendor/include/networkit/centrality/KadabraBetweenness.hpp +242 -0
- package/vendor/include/networkit/centrality/KatzCentrality.hpp +62 -0
- package/vendor/include/networkit/centrality/LaplacianCentrality.hpp +44 -0
- package/vendor/include/networkit/centrality/LocalClusteringCoefficient.hpp +60 -0
- package/vendor/include/networkit/centrality/LocalPartitionCoverage.hpp +43 -0
- package/vendor/include/networkit/centrality/LocalSquareClusteringCoefficient.hpp +42 -0
- package/vendor/include/networkit/centrality/PageRank.hpp +101 -0
- package/vendor/include/networkit/centrality/PermanenceCentrality.hpp +48 -0
- package/vendor/include/networkit/centrality/Sfigality.hpp +45 -0
- package/vendor/include/networkit/centrality/SpanningEdgeCentrality.hpp +86 -0
- package/vendor/include/networkit/centrality/TopCloseness.hpp +136 -0
- package/vendor/include/networkit/centrality/TopHarmonicCloseness.hpp +151 -0
- package/vendor/include/networkit/clique/MaximalCliques.hpp +83 -0
- package/vendor/include/networkit/coarsening/ClusteringProjector.hpp +59 -0
- package/vendor/include/networkit/coarsening/CoarsenedGraphView.hpp +156 -0
- package/vendor/include/networkit/coarsening/GraphCoarsening.hpp +57 -0
- package/vendor/include/networkit/coarsening/MatchingCoarsening.hpp +43 -0
- package/vendor/include/networkit/coarsening/ParallelPartitionCoarsening.hpp +33 -0
- package/vendor/include/networkit/coarsening/ParallelPartitionCoarseningView.hpp +62 -0
- package/vendor/include/networkit/community/AdjustedRandMeasure.hpp +31 -0
- package/vendor/include/networkit/community/ClusteringGenerator.hpp +75 -0
- package/vendor/include/networkit/community/CommunityDetectionAlgorithm.hpp +58 -0
- package/vendor/include/networkit/community/Conductance.hpp +32 -0
- package/vendor/include/networkit/community/CoverF1Similarity.hpp +53 -0
- package/vendor/include/networkit/community/CoverHubDominance.hpp +38 -0
- package/vendor/include/networkit/community/Coverage.hpp +25 -0
- package/vendor/include/networkit/community/CutClustering.hpp +62 -0
- package/vendor/include/networkit/community/DissimilarityMeasure.hpp +31 -0
- package/vendor/include/networkit/community/DynamicNMIDistance.hpp +44 -0
- package/vendor/include/networkit/community/EdgeCut.hpp +24 -0
- package/vendor/include/networkit/community/GraphClusteringTools.hpp +103 -0
- package/vendor/include/networkit/community/GraphStructuralRandMeasure.hpp +28 -0
- package/vendor/include/networkit/community/HubDominance.hpp +46 -0
- package/vendor/include/networkit/community/IntrapartitionDensity.hpp +44 -0
- package/vendor/include/networkit/community/IsolatedInterpartitionConductance.hpp +40 -0
- package/vendor/include/networkit/community/IsolatedInterpartitionExpansion.hpp +40 -0
- package/vendor/include/networkit/community/JaccardMeasure.hpp +25 -0
- package/vendor/include/networkit/community/LFM.hpp +49 -0
- package/vendor/include/networkit/community/LPDegreeOrdered.hpp +48 -0
- package/vendor/include/networkit/community/LocalCommunityEvaluation.hpp +100 -0
- package/vendor/include/networkit/community/LocalCoverEvaluation.hpp +31 -0
- package/vendor/include/networkit/community/LocalPartitionEvaluation.hpp +31 -0
- package/vendor/include/networkit/community/LouvainMapEquation.hpp +135 -0
- package/vendor/include/networkit/community/Modularity.hpp +54 -0
- package/vendor/include/networkit/community/NMIDistance.hpp +28 -0
- package/vendor/include/networkit/community/NodeStructuralRandMeasure.hpp +27 -0
- package/vendor/include/networkit/community/OverlappingCommunityDetectionAlgorithm.hpp +51 -0
- package/vendor/include/networkit/community/OverlappingNMIDistance.hpp +175 -0
- package/vendor/include/networkit/community/PLM.hpp +89 -0
- package/vendor/include/networkit/community/PLP.hpp +83 -0
- package/vendor/include/networkit/community/ParallelAgglomerativeClusterer.hpp +37 -0
- package/vendor/include/networkit/community/ParallelLeiden.hpp +96 -0
- package/vendor/include/networkit/community/ParallelLeidenView.hpp +138 -0
- package/vendor/include/networkit/community/PartitionFragmentation.hpp +30 -0
- package/vendor/include/networkit/community/PartitionHubDominance.hpp +37 -0
- package/vendor/include/networkit/community/PartitionIntersection.hpp +25 -0
- package/vendor/include/networkit/community/QualityMeasure.hpp +27 -0
- package/vendor/include/networkit/community/SampledGraphStructuralRandMeasure.hpp +40 -0
- package/vendor/include/networkit/community/SampledNodeStructuralRandMeasure.hpp +40 -0
- package/vendor/include/networkit/community/StablePartitionNodes.hpp +48 -0
- package/vendor/include/networkit/components/BiconnectedComponents.hpp +116 -0
- package/vendor/include/networkit/components/ComponentDecomposition.hpp +72 -0
- package/vendor/include/networkit/components/ConnectedComponents.hpp +55 -0
- package/vendor/include/networkit/components/DynConnectedComponents.hpp +71 -0
- package/vendor/include/networkit/components/DynWeaklyConnectedComponents.hpp +73 -0
- package/vendor/include/networkit/components/ParallelConnectedComponents.hpp +44 -0
- package/vendor/include/networkit/components/RandomSpanningForest.hpp +36 -0
- package/vendor/include/networkit/components/StronglyConnectedComponents.hpp +50 -0
- package/vendor/include/networkit/components/WeaklyConnectedComponents.hpp +59 -0
- package/vendor/include/networkit/correlation/Assortativity.hpp +64 -0
- package/vendor/include/networkit/distance/APSP.hpp +70 -0
- package/vendor/include/networkit/distance/AStar.hpp +68 -0
- package/vendor/include/networkit/distance/AStarGeneral.hpp +110 -0
- package/vendor/include/networkit/distance/AdamicAdarDistance.hpp +52 -0
- package/vendor/include/networkit/distance/AffectedNodes.hpp +130 -0
- package/vendor/include/networkit/distance/AlgebraicDistance.hpp +63 -0
- package/vendor/include/networkit/distance/BFS.hpp +43 -0
- package/vendor/include/networkit/distance/BidirectionalBFS.hpp +51 -0
- package/vendor/include/networkit/distance/BidirectionalDijkstra.hpp +69 -0
- package/vendor/include/networkit/distance/CommuteTimeDistance.hpp +89 -0
- package/vendor/include/networkit/distance/Diameter.hpp +97 -0
- package/vendor/include/networkit/distance/Dijkstra.hpp +50 -0
- package/vendor/include/networkit/distance/DynAPSP.hpp +67 -0
- package/vendor/include/networkit/distance/DynBFS.hpp +56 -0
- package/vendor/include/networkit/distance/DynDijkstra.hpp +57 -0
- package/vendor/include/networkit/distance/DynPrunedLandmarkLabeling.hpp +67 -0
- package/vendor/include/networkit/distance/DynSSSP.hpp +87 -0
- package/vendor/include/networkit/distance/Eccentricity.hpp +32 -0
- package/vendor/include/networkit/distance/EffectiveDiameter.hpp +47 -0
- package/vendor/include/networkit/distance/EffectiveDiameterApproximation.hpp +57 -0
- package/vendor/include/networkit/distance/FloydWarshall.hpp +93 -0
- package/vendor/include/networkit/distance/GraphDistance.hpp +49 -0
- package/vendor/include/networkit/distance/HopPlotApproximation.hpp +62 -0
- package/vendor/include/networkit/distance/IncompleteDijkstra.hpp +66 -0
- package/vendor/include/networkit/distance/IncompleteSSSP.hpp +41 -0
- package/vendor/include/networkit/distance/JaccardDistance.hpp +57 -0
- package/vendor/include/networkit/distance/MultiTargetBFS.hpp +32 -0
- package/vendor/include/networkit/distance/MultiTargetDijkstra.hpp +40 -0
- package/vendor/include/networkit/distance/NeighborhoodFunction.hpp +47 -0
- package/vendor/include/networkit/distance/NeighborhoodFunctionApproximation.hpp +56 -0
- package/vendor/include/networkit/distance/NeighborhoodFunctionHeuristic.hpp +56 -0
- package/vendor/include/networkit/distance/NodeDistance.hpp +54 -0
- package/vendor/include/networkit/distance/PrunedLandmarkLabeling.hpp +76 -0
- package/vendor/include/networkit/distance/ReverseBFS.hpp +46 -0
- package/vendor/include/networkit/distance/SPSP.hpp +143 -0
- package/vendor/include/networkit/distance/SSSP.hpp +216 -0
- package/vendor/include/networkit/distance/STSP.hpp +193 -0
- package/vendor/include/networkit/distance/Volume.hpp +66 -0
- package/vendor/include/networkit/dynamics/DGSStreamParser.hpp +40 -0
- package/vendor/include/networkit/dynamics/DGSWriter.hpp +30 -0
- package/vendor/include/networkit/dynamics/GraphDifference.hpp +110 -0
- package/vendor/include/networkit/dynamics/GraphEvent.hpp +55 -0
- package/vendor/include/networkit/dynamics/GraphEventHandler.hpp +39 -0
- package/vendor/include/networkit/dynamics/GraphEventProxy.hpp +55 -0
- package/vendor/include/networkit/dynamics/GraphUpdater.hpp +38 -0
- package/vendor/include/networkit/edgescores/ChibaNishizekiQuadrangleEdgeScore.hpp +26 -0
- package/vendor/include/networkit/edgescores/ChibaNishizekiTriangleEdgeScore.hpp +33 -0
- package/vendor/include/networkit/edgescores/EdgeScore.hpp +50 -0
- package/vendor/include/networkit/edgescores/EdgeScoreAsWeight.hpp +33 -0
- package/vendor/include/networkit/edgescores/EdgeScoreBlender.hpp +33 -0
- package/vendor/include/networkit/edgescores/EdgeScoreLinearizer.hpp +32 -0
- package/vendor/include/networkit/edgescores/EdgeScoreNormalizer.hpp +35 -0
- package/vendor/include/networkit/edgescores/GeometricMeanScore.hpp +29 -0
- package/vendor/include/networkit/edgescores/PrefixJaccardScore.hpp +23 -0
- package/vendor/include/networkit/edgescores/TriangleEdgeScore.hpp +39 -0
- package/vendor/include/networkit/embedding/Node2Vec.hpp +83 -0
- package/vendor/include/networkit/flow/EdmondsKarp.hpp +112 -0
- package/vendor/include/networkit/generators/BarabasiAlbertGenerator.hpp +87 -0
- package/vendor/include/networkit/generators/ChungLuGenerator.hpp +46 -0
- package/vendor/include/networkit/generators/ChungLuGeneratorAlamEtAl.hpp +63 -0
- package/vendor/include/networkit/generators/ClusteredRandomGraphGenerator.hpp +56 -0
- package/vendor/include/networkit/generators/ConfigurationModel.hpp +36 -0
- package/vendor/include/networkit/generators/DorogovtsevMendesGenerator.hpp +33 -0
- package/vendor/include/networkit/generators/DynamicBarabasiAlbertGenerator.hpp +33 -0
- package/vendor/include/networkit/generators/DynamicDGSParser.hpp +51 -0
- package/vendor/include/networkit/generators/DynamicDorogovtsevMendesGenerator.hpp +34 -0
- package/vendor/include/networkit/generators/DynamicForestFireGenerator.hpp +55 -0
- package/vendor/include/networkit/generators/DynamicGraphGenerator.hpp +40 -0
- package/vendor/include/networkit/generators/DynamicGraphSource.hpp +79 -0
- package/vendor/include/networkit/generators/DynamicHyperbolicGenerator.hpp +143 -0
- package/vendor/include/networkit/generators/DynamicPathGenerator.hpp +26 -0
- package/vendor/include/networkit/generators/DynamicPubWebGenerator.hpp +54 -0
- package/vendor/include/networkit/generators/EdgeSwitchingMarkovChainGenerator.hpp +65 -0
- package/vendor/include/networkit/generators/ErdosRenyiEnumerator.hpp +318 -0
- package/vendor/include/networkit/generators/ErdosRenyiGenerator.hpp +56 -0
- package/vendor/include/networkit/generators/HavelHakimiGenerator.hpp +48 -0
- package/vendor/include/networkit/generators/HyperbolicGenerator.hpp +236 -0
- package/vendor/include/networkit/generators/LFRGenerator.hpp +175 -0
- package/vendor/include/networkit/generators/MocnikGenerator.hpp +147 -0
- package/vendor/include/networkit/generators/MocnikGeneratorBasic.hpp +58 -0
- package/vendor/include/networkit/generators/PowerlawDegreeSequence.hpp +128 -0
- package/vendor/include/networkit/generators/PubWebGenerator.hpp +94 -0
- package/vendor/include/networkit/generators/RegularRingLatticeGenerator.hpp +37 -0
- package/vendor/include/networkit/generators/RmatGenerator.hpp +67 -0
- package/vendor/include/networkit/generators/StaticDegreeSequenceGenerator.hpp +42 -0
- package/vendor/include/networkit/generators/StaticGraphGenerator.hpp +30 -0
- package/vendor/include/networkit/generators/StochasticBlockmodel.hpp +41 -0
- package/vendor/include/networkit/generators/WattsStrogatzGenerator.hpp +43 -0
- package/vendor/include/networkit/generators/quadtree/QuadNode.hpp +857 -0
- package/vendor/include/networkit/generators/quadtree/QuadNodeCartesianEuclid.hpp +587 -0
- package/vendor/include/networkit/generators/quadtree/QuadNodePolarEuclid.hpp +726 -0
- package/vendor/include/networkit/generators/quadtree/Quadtree.hpp +232 -0
- package/vendor/include/networkit/generators/quadtree/QuadtreeCartesianEuclid.hpp +149 -0
- package/vendor/include/networkit/generators/quadtree/QuadtreePolarEuclid.hpp +143 -0
- package/vendor/include/networkit/geometric/HyperbolicSpace.hpp +248 -0
- package/vendor/include/networkit/geometric/Point2DWithIndex.hpp +145 -0
- package/vendor/include/networkit/global/ClusteringCoefficient.hpp +42 -0
- package/vendor/include/networkit/global/GlobalClusteringCoefficient.hpp +24 -0
- package/vendor/include/networkit/graph/Attributes.hpp +568 -0
- package/vendor/include/networkit/graph/BFS.hpp +111 -0
- package/vendor/include/networkit/graph/DFS.hpp +71 -0
- package/vendor/include/networkit/graph/Dijkstra.hpp +83 -0
- package/vendor/include/networkit/graph/EdgeIterators.hpp +171 -0
- package/vendor/include/networkit/graph/Graph.hpp +2083 -0
- package/vendor/include/networkit/graph/GraphBuilder.hpp +289 -0
- package/vendor/include/networkit/graph/GraphR.hpp +133 -0
- package/vendor/include/networkit/graph/GraphTools.hpp +589 -0
- package/vendor/include/networkit/graph/GraphW.hpp +1236 -0
- package/vendor/include/networkit/graph/KruskalMSF.hpp +50 -0
- package/vendor/include/networkit/graph/NeighborIterators.hpp +163 -0
- package/vendor/include/networkit/graph/NodeIterators.hpp +127 -0
- package/vendor/include/networkit/graph/PrimMSF.hpp +66 -0
- package/vendor/include/networkit/graph/RandomMaximumSpanningForest.hpp +133 -0
- package/vendor/include/networkit/graph/SpanningForest.hpp +41 -0
- package/vendor/include/networkit/graph/TopologicalSort.hpp +87 -0
- package/vendor/include/networkit/graph/UnionMaximumSpanningForest.hpp +126 -0
- package/vendor/include/networkit/graph/test/GraphBuilderBenchmark.hpp +68 -0
- package/vendor/include/networkit/independentset/IndependentSetFinder.hpp +44 -0
- package/vendor/include/networkit/independentset/Luby.hpp +27 -0
- package/vendor/include/networkit/io/BinaryEdgeListPartitionReader.hpp +45 -0
- package/vendor/include/networkit/io/BinaryEdgeListPartitionWriter.hpp +47 -0
- package/vendor/include/networkit/io/BinaryPartitionReader.hpp +41 -0
- package/vendor/include/networkit/io/BinaryPartitionWriter.hpp +44 -0
- package/vendor/include/networkit/io/CoverReader.hpp +27 -0
- package/vendor/include/networkit/io/CoverWriter.hpp +21 -0
- package/vendor/include/networkit/io/DGSReader.hpp +39 -0
- package/vendor/include/networkit/io/DibapGraphReader.hpp +43 -0
- package/vendor/include/networkit/io/DotGraphWriter.hpp +39 -0
- package/vendor/include/networkit/io/DotPartitionWriter.hpp +23 -0
- package/vendor/include/networkit/io/DynamicGraphReader.hpp +29 -0
- package/vendor/include/networkit/io/EdgeListCoverReader.hpp +35 -0
- package/vendor/include/networkit/io/EdgeListPartitionReader.hpp +43 -0
- package/vendor/include/networkit/io/EdgeListReader.hpp +61 -0
- package/vendor/include/networkit/io/EdgeListWriter.hpp +48 -0
- package/vendor/include/networkit/io/GMLGraphReader.hpp +33 -0
- package/vendor/include/networkit/io/GMLGraphWriter.hpp +33 -0
- package/vendor/include/networkit/io/GraphIO.hpp +52 -0
- package/vendor/include/networkit/io/GraphReader.hpp +40 -0
- package/vendor/include/networkit/io/GraphToolBinaryReader.hpp +71 -0
- package/vendor/include/networkit/io/GraphToolBinaryWriter.hpp +61 -0
- package/vendor/include/networkit/io/GraphWriter.hpp +27 -0
- package/vendor/include/networkit/io/KONECTGraphReader.hpp +44 -0
- package/vendor/include/networkit/io/LineFileReader.hpp +42 -0
- package/vendor/include/networkit/io/METISGraphReader.hpp +36 -0
- package/vendor/include/networkit/io/METISGraphWriter.hpp +29 -0
- package/vendor/include/networkit/io/METISParser.hpp +63 -0
- package/vendor/include/networkit/io/MTXGraphReader.hpp +31 -0
- package/vendor/include/networkit/io/MTXParser.hpp +87 -0
- package/vendor/include/networkit/io/MatrixMarketReader.hpp +33 -0
- package/vendor/include/networkit/io/MatrixReader.hpp +33 -0
- package/vendor/include/networkit/io/MemoryMappedFile.hpp +80 -0
- package/vendor/include/networkit/io/NetworkitBinaryGraph.hpp +144 -0
- package/vendor/include/networkit/io/NetworkitBinaryReader.hpp +50 -0
- package/vendor/include/networkit/io/NetworkitBinaryWriter.hpp +71 -0
- package/vendor/include/networkit/io/PartitionReader.hpp +34 -0
- package/vendor/include/networkit/io/PartitionWriter.hpp +31 -0
- package/vendor/include/networkit/io/RBGraphReader.hpp +37 -0
- package/vendor/include/networkit/io/RBMatrixReader.hpp +49 -0
- package/vendor/include/networkit/io/RasterReader.hpp +40 -0
- package/vendor/include/networkit/io/SNAPEdgeListPartitionReader.hpp +28 -0
- package/vendor/include/networkit/io/SNAPGraphReader.hpp +53 -0
- package/vendor/include/networkit/io/SNAPGraphWriter.hpp +53 -0
- package/vendor/include/networkit/io/ThrillGraphBinaryReader.hpp +44 -0
- package/vendor/include/networkit/io/ThrillGraphBinaryWriter.hpp +27 -0
- package/vendor/include/networkit/layout/LayoutAlgorithm.hpp +39 -0
- package/vendor/include/networkit/linkprediction/AdamicAdarIndex.hpp +37 -0
- package/vendor/include/networkit/linkprediction/AdjustedRandIndex.hpp +36 -0
- package/vendor/include/networkit/linkprediction/AlgebraicDistanceIndex.hpp +70 -0
- package/vendor/include/networkit/linkprediction/CommonNeighborsIndex.hpp +39 -0
- package/vendor/include/networkit/linkprediction/EvaluationMetric.hpp +135 -0
- package/vendor/include/networkit/linkprediction/JaccardIndex.hpp +44 -0
- package/vendor/include/networkit/linkprediction/KatzIndex.hpp +84 -0
- package/vendor/include/networkit/linkprediction/LinkPredictor.hpp +98 -0
- package/vendor/include/networkit/linkprediction/LinkThresholder.hpp +56 -0
- package/vendor/include/networkit/linkprediction/MissingLinksFinder.hpp +60 -0
- package/vendor/include/networkit/linkprediction/NeighborhoodDistanceIndex.hpp +42 -0
- package/vendor/include/networkit/linkprediction/NeighborhoodUtility.hpp +54 -0
- package/vendor/include/networkit/linkprediction/NeighborsMeasureIndex.hpp +48 -0
- package/vendor/include/networkit/linkprediction/PrecisionRecallMetric.hpp +40 -0
- package/vendor/include/networkit/linkprediction/PredictionsSorter.hpp +66 -0
- package/vendor/include/networkit/linkprediction/PreferentialAttachmentIndex.hpp +37 -0
- package/vendor/include/networkit/linkprediction/ROCMetric.hpp +39 -0
- package/vendor/include/networkit/linkprediction/RandomLinkSampler.hpp +47 -0
- package/vendor/include/networkit/linkprediction/ResourceAllocationIndex.hpp +38 -0
- package/vendor/include/networkit/linkprediction/SameCommunityIndex.hpp +50 -0
- package/vendor/include/networkit/linkprediction/TotalNeighborsIndex.hpp +39 -0
- package/vendor/include/networkit/linkprediction/UDegreeIndex.hpp +35 -0
- package/vendor/include/networkit/linkprediction/VDegreeIndex.hpp +35 -0
- package/vendor/include/networkit/matching/BMatcher.hpp +52 -0
- package/vendor/include/networkit/matching/BMatching.hpp +115 -0
- package/vendor/include/networkit/matching/BSuitorMatcher.hpp +170 -0
- package/vendor/include/networkit/matching/DynamicBSuitorMatcher.hpp +78 -0
- package/vendor/include/networkit/matching/LocalMaxMatcher.hpp +35 -0
- package/vendor/include/networkit/matching/Matcher.hpp +55 -0
- package/vendor/include/networkit/matching/Matching.hpp +111 -0
- package/vendor/include/networkit/matching/PathGrowingMatcher.hpp +46 -0
- package/vendor/include/networkit/matching/SuitorMatcher.hpp +62 -0
- package/vendor/include/networkit/numerics/ConjugateGradient.hpp +163 -0
- package/vendor/include/networkit/numerics/GaussSeidelRelaxation.hpp +99 -0
- package/vendor/include/networkit/numerics/LAMG/LAMGSettings.hpp +70 -0
- package/vendor/include/networkit/numerics/LAMG/Lamg.hpp +460 -0
- package/vendor/include/networkit/numerics/LAMG/Level/EliminationStage.hpp +47 -0
- package/vendor/include/networkit/numerics/LAMG/Level/Level.hpp +56 -0
- package/vendor/include/networkit/numerics/LAMG/Level/LevelAggregation.hpp +52 -0
- package/vendor/include/networkit/numerics/LAMG/Level/LevelElimination.hpp +133 -0
- package/vendor/include/networkit/numerics/LAMG/Level/LevelFinest.hpp +28 -0
- package/vendor/include/networkit/numerics/LAMG/LevelHierarchy.hpp +165 -0
- package/vendor/include/networkit/numerics/LAMG/MultiLevelSetup.hpp +1090 -0
- package/vendor/include/networkit/numerics/LAMG/SolverLamg.hpp +316 -0
- package/vendor/include/networkit/numerics/LinearSolver.hpp +151 -0
- package/vendor/include/networkit/numerics/Preconditioner/DiagonalPreconditioner.hpp +61 -0
- package/vendor/include/networkit/numerics/Preconditioner/IdentityPreconditioner.hpp +36 -0
- package/vendor/include/networkit/numerics/Smoother.hpp +37 -0
- package/vendor/include/networkit/overlap/HashingOverlapper.hpp +28 -0
- package/vendor/include/networkit/overlap/Overlapper.hpp +27 -0
- package/vendor/include/networkit/planarity/LeftRightPlanarityCheck.hpp +113 -0
- package/vendor/include/networkit/randomization/Curveball.hpp +49 -0
- package/vendor/include/networkit/randomization/CurveballGlobalTradeGenerator.hpp +39 -0
- package/vendor/include/networkit/randomization/CurveballUniformTradeGenerator.hpp +39 -0
- package/vendor/include/networkit/randomization/DegreePreservingShuffle.hpp +82 -0
- package/vendor/include/networkit/randomization/EdgeSwitching.hpp +157 -0
- package/vendor/include/networkit/randomization/GlobalCurveball.hpp +69 -0
- package/vendor/include/networkit/randomization/GlobalTradeSequence.hpp +303 -0
- package/vendor/include/networkit/reachability/AllSimplePaths.hpp +122 -0
- package/vendor/include/networkit/reachability/ReachableNodes.hpp +83 -0
- package/vendor/include/networkit/scd/ApproximatePageRank.hpp +51 -0
- package/vendor/include/networkit/scd/CliqueDetect.hpp +55 -0
- package/vendor/include/networkit/scd/CombinedSCD.hpp +51 -0
- package/vendor/include/networkit/scd/GCE.hpp +42 -0
- package/vendor/include/networkit/scd/LFMLocal.hpp +54 -0
- package/vendor/include/networkit/scd/LocalT.hpp +40 -0
- package/vendor/include/networkit/scd/LocalTightnessExpansion.hpp +46 -0
- package/vendor/include/networkit/scd/PageRankNibble.hpp +55 -0
- package/vendor/include/networkit/scd/RandomBFS.hpp +33 -0
- package/vendor/include/networkit/scd/SCDGroundTruthComparison.hpp +121 -0
- package/vendor/include/networkit/scd/SelectiveCommunityDetector.hpp +76 -0
- package/vendor/include/networkit/scd/SetConductance.hpp +47 -0
- package/vendor/include/networkit/scd/TCE.hpp +41 -0
- package/vendor/include/networkit/scd/TwoPhaseL.hpp +40 -0
- package/vendor/include/networkit/scoring/EdgeScoring.hpp +44 -0
- package/vendor/include/networkit/scoring/ModularityScoring.hpp +79 -0
- package/vendor/include/networkit/simulation/EpidemicSimulationSEIR.hpp +59 -0
- package/vendor/include/networkit/sparsification/ChanceCorrectedTriangleScore.hpp +28 -0
- package/vendor/include/networkit/sparsification/ForestFireScore.hpp +34 -0
- package/vendor/include/networkit/sparsification/GlobalThresholdFilter.hpp +40 -0
- package/vendor/include/networkit/sparsification/LocalDegreeScore.hpp +30 -0
- package/vendor/include/networkit/sparsification/LocalFilterScore.hpp +124 -0
- package/vendor/include/networkit/sparsification/LocalSimilarityScore.hpp +63 -0
- package/vendor/include/networkit/sparsification/MultiscaleScore.hpp +38 -0
- package/vendor/include/networkit/sparsification/RandomEdgeScore.hpp +33 -0
- package/vendor/include/networkit/sparsification/RandomNodeEdgeScore.hpp +29 -0
- package/vendor/include/networkit/sparsification/SCANStructuralSimilarityScore.hpp +23 -0
- package/vendor/include/networkit/sparsification/SimmelianOverlapScore.hpp +35 -0
- package/vendor/include/networkit/sparsification/SimmelianScore.hpp +92 -0
- package/vendor/include/networkit/sparsification/Sparsifiers.hpp +166 -0
- package/vendor/include/networkit/structures/Cover.hpp +248 -0
- package/vendor/include/networkit/structures/LocalCommunity.hpp +363 -0
- package/vendor/include/networkit/structures/Partition.hpp +335 -0
- package/vendor/include/networkit/structures/UnionFind.hpp +66 -0
- package/vendor/include/networkit/viz/GraphLayoutAlgorithm.hpp +157 -0
- package/vendor/include/networkit/viz/MaxentStress.hpp +346 -0
- package/vendor/include/networkit/viz/Octree.hpp +428 -0
- package/vendor/include/networkit/viz/PivotMDS.hpp +63 -0
- package/vendor/include/networkit/viz/Point.hpp +415 -0
- package/vendor/include/networkit/viz/PostscriptWriter.hpp +78 -0
- package/vendor/include/tlx/algorithm/exclusive_scan.hpp +56 -0
- package/vendor/include/tlx/algorithm/is_sorted_cmp.hpp +56 -0
- package/vendor/include/tlx/algorithm/merge_advance.hpp +177 -0
- package/vendor/include/tlx/algorithm/merge_combine.hpp +76 -0
- package/vendor/include/tlx/algorithm/multisequence_partition.hpp +346 -0
- package/vendor/include/tlx/algorithm/multisequence_selection.hpp +351 -0
- package/vendor/include/tlx/algorithm/multiway_merge.hpp +1385 -0
- package/vendor/include/tlx/algorithm/multiway_merge_splitting.hpp +257 -0
- package/vendor/include/tlx/algorithm/parallel_multiway_merge.hpp +408 -0
- package/vendor/include/tlx/algorithm/random_bipartition_shuffle.hpp +116 -0
- package/vendor/include/tlx/algorithm.hpp +36 -0
- package/vendor/include/tlx/allocator_base.hpp +100 -0
- package/vendor/include/tlx/backtrace.hpp +54 -0
- package/vendor/include/tlx/cmdline_parser.hpp +498 -0
- package/vendor/include/tlx/container/btree.hpp +3977 -0
- package/vendor/include/tlx/container/btree_map.hpp +634 -0
- package/vendor/include/tlx/container/btree_multimap.hpp +627 -0
- package/vendor/include/tlx/container/btree_multiset.hpp +612 -0
- package/vendor/include/tlx/container/btree_set.hpp +612 -0
- package/vendor/include/tlx/container/d_ary_addressable_int_heap.hpp +416 -0
- package/vendor/include/tlx/container/d_ary_heap.hpp +311 -0
- package/vendor/include/tlx/container/loser_tree.hpp +1009 -0
- package/vendor/include/tlx/container/lru_cache.hpp +319 -0
- package/vendor/include/tlx/container/radix_heap.hpp +735 -0
- package/vendor/include/tlx/container/ring_buffer.hpp +428 -0
- package/vendor/include/tlx/container/simple_vector.hpp +304 -0
- package/vendor/include/tlx/container/splay_tree.hpp +399 -0
- package/vendor/include/tlx/container/string_view.hpp +805 -0
- package/vendor/include/tlx/container.hpp +40 -0
- package/vendor/include/tlx/counting_ptr.hpp +522 -0
- package/vendor/include/tlx/define/attribute_always_inline.hpp +34 -0
- package/vendor/include/tlx/define/attribute_fallthrough.hpp +36 -0
- package/vendor/include/tlx/define/attribute_format_printf.hpp +34 -0
- package/vendor/include/tlx/define/attribute_packed.hpp +34 -0
- package/vendor/include/tlx/define/attribute_warn_unused_result.hpp +34 -0
- package/vendor/include/tlx/define/constexpr.hpp +31 -0
- package/vendor/include/tlx/define/deprecated.hpp +39 -0
- package/vendor/include/tlx/define/endian.hpp +49 -0
- package/vendor/include/tlx/define/likely.hpp +33 -0
- package/vendor/include/tlx/define/visibility_hidden.hpp +34 -0
- package/vendor/include/tlx/define.hpp +36 -0
- package/vendor/include/tlx/delegate.hpp +524 -0
- package/vendor/include/tlx/die/core.hpp +311 -0
- package/vendor/include/tlx/die.hpp +106 -0
- package/vendor/include/tlx/digest/md5.hpp +81 -0
- package/vendor/include/tlx/digest/sha1.hpp +81 -0
- package/vendor/include/tlx/digest/sha256.hpp +81 -0
- package/vendor/include/tlx/digest/sha512.hpp +81 -0
- package/vendor/include/tlx/digest.hpp +30 -0
- package/vendor/include/tlx/logger/all.hpp +33 -0
- package/vendor/include/tlx/logger/array.hpp +43 -0
- package/vendor/include/tlx/logger/core.hpp +287 -0
- package/vendor/include/tlx/logger/deque.hpp +42 -0
- package/vendor/include/tlx/logger/map.hpp +65 -0
- package/vendor/include/tlx/logger/set.hpp +60 -0
- package/vendor/include/tlx/logger/tuple.hpp +66 -0
- package/vendor/include/tlx/logger/unordered_map.hpp +68 -0
- package/vendor/include/tlx/logger/unordered_set.hpp +64 -0
- package/vendor/include/tlx/logger/wrap_unprintable.hpp +75 -0
- package/vendor/include/tlx/logger.hpp +44 -0
- package/vendor/include/tlx/math/abs_diff.hpp +35 -0
- package/vendor/include/tlx/math/aggregate.hpp +231 -0
- package/vendor/include/tlx/math/aggregate_min_max.hpp +116 -0
- package/vendor/include/tlx/math/bswap.hpp +148 -0
- package/vendor/include/tlx/math/bswap_be.hpp +79 -0
- package/vendor/include/tlx/math/bswap_le.hpp +79 -0
- package/vendor/include/tlx/math/clz.hpp +174 -0
- package/vendor/include/tlx/math/ctz.hpp +174 -0
- package/vendor/include/tlx/math/div_ceil.hpp +36 -0
- package/vendor/include/tlx/math/ffs.hpp +123 -0
- package/vendor/include/tlx/math/integer_log2.hpp +189 -0
- package/vendor/include/tlx/math/is_power_of_two.hpp +74 -0
- package/vendor/include/tlx/math/polynomial_regression.hpp +243 -0
- package/vendor/include/tlx/math/popcount.hpp +173 -0
- package/vendor/include/tlx/math/power_to_the.hpp +44 -0
- package/vendor/include/tlx/math/rol.hpp +112 -0
- package/vendor/include/tlx/math/ror.hpp +112 -0
- package/vendor/include/tlx/math/round_to_power_of_two.hpp +121 -0
- package/vendor/include/tlx/math/round_up.hpp +36 -0
- package/vendor/include/tlx/math/sgn.hpp +38 -0
- package/vendor/include/tlx/math.hpp +46 -0
- package/vendor/include/tlx/meta/apply_tuple.hpp +55 -0
- package/vendor/include/tlx/meta/call_for_range.hpp +78 -0
- package/vendor/include/tlx/meta/call_foreach.hpp +60 -0
- package/vendor/include/tlx/meta/call_foreach_tuple.hpp +60 -0
- package/vendor/include/tlx/meta/call_foreach_tuple_with_index.hpp +61 -0
- package/vendor/include/tlx/meta/call_foreach_with_index.hpp +64 -0
- package/vendor/include/tlx/meta/enable_if.hpp +37 -0
- package/vendor/include/tlx/meta/fold_left.hpp +63 -0
- package/vendor/include/tlx/meta/fold_left_tuple.hpp +60 -0
- package/vendor/include/tlx/meta/fold_right.hpp +63 -0
- package/vendor/include/tlx/meta/fold_right_tuple.hpp +60 -0
- package/vendor/include/tlx/meta/function_chain.hpp +197 -0
- package/vendor/include/tlx/meta/function_stack.hpp +189 -0
- package/vendor/include/tlx/meta/has_member.hpp +80 -0
- package/vendor/include/tlx/meta/has_method.hpp +117 -0
- package/vendor/include/tlx/meta/index_sequence.hpp +66 -0
- package/vendor/include/tlx/meta/is_std_array.hpp +40 -0
- package/vendor/include/tlx/meta/is_std_pair.hpp +39 -0
- package/vendor/include/tlx/meta/is_std_tuple.hpp +39 -0
- package/vendor/include/tlx/meta/is_std_vector.hpp +39 -0
- package/vendor/include/tlx/meta/log2.hpp +101 -0
- package/vendor/include/tlx/meta/no_operation.hpp +55 -0
- package/vendor/include/tlx/meta/static_index.hpp +42 -0
- package/vendor/include/tlx/meta/vexpand.hpp +34 -0
- package/vendor/include/tlx/meta/vmap_for_range.hpp +84 -0
- package/vendor/include/tlx/meta/vmap_foreach.hpp +63 -0
- package/vendor/include/tlx/meta/vmap_foreach_tuple.hpp +59 -0
- package/vendor/include/tlx/meta/vmap_foreach_tuple_with_index.hpp +62 -0
- package/vendor/include/tlx/meta/vmap_foreach_with_index.hpp +70 -0
- package/vendor/include/tlx/meta.hpp +55 -0
- package/vendor/include/tlx/multi_timer.hpp +148 -0
- package/vendor/include/tlx/port/setenv.hpp +31 -0
- package/vendor/include/tlx/port.hpp +27 -0
- package/vendor/include/tlx/semaphore.hpp +119 -0
- package/vendor/include/tlx/simple_vector.hpp +20 -0
- package/vendor/include/tlx/siphash.hpp +282 -0
- package/vendor/include/tlx/sort/networks/best.hpp +611 -0
- package/vendor/include/tlx/sort/networks/bose_nelson.hpp +412 -0
- package/vendor/include/tlx/sort/networks/bose_nelson_parameter.hpp +507 -0
- package/vendor/include/tlx/sort/networks/cswap.hpp +60 -0
- package/vendor/include/tlx/sort/parallel_mergesort.hpp +398 -0
- package/vendor/include/tlx/sort/strings/insertion_sort.hpp +232 -0
- package/vendor/include/tlx/sort/strings/multikey_quicksort.hpp +185 -0
- package/vendor/include/tlx/sort/strings/parallel_sample_sort.hpp +1647 -0
- package/vendor/include/tlx/sort/strings/radix_sort.hpp +934 -0
- package/vendor/include/tlx/sort/strings/sample_sort_tools.hpp +756 -0
- package/vendor/include/tlx/sort/strings/string_ptr.hpp +426 -0
- package/vendor/include/tlx/sort/strings/string_set.hpp +800 -0
- package/vendor/include/tlx/sort/strings.hpp +329 -0
- package/vendor/include/tlx/sort/strings_parallel.hpp +325 -0
- package/vendor/include/tlx/sort.hpp +29 -0
- package/vendor/include/tlx/stack_allocator.hpp +226 -0
- package/vendor/include/tlx/string/appendline.hpp +35 -0
- package/vendor/include/tlx/string/base64.hpp +87 -0
- package/vendor/include/tlx/string/bitdump.hpp +139 -0
- package/vendor/include/tlx/string/compare_icase.hpp +42 -0
- package/vendor/include/tlx/string/contains.hpp +36 -0
- package/vendor/include/tlx/string/contains_word.hpp +42 -0
- package/vendor/include/tlx/string/ends_with.hpp +79 -0
- package/vendor/include/tlx/string/equal_icase.hpp +42 -0
- package/vendor/include/tlx/string/erase_all.hpp +70 -0
- package/vendor/include/tlx/string/escape_html.hpp +34 -0
- package/vendor/include/tlx/string/escape_uri.hpp +34 -0
- package/vendor/include/tlx/string/expand_environment_variables.hpp +49 -0
- package/vendor/include/tlx/string/extract_between.hpp +40 -0
- package/vendor/include/tlx/string/format_iec_units.hpp +32 -0
- package/vendor/include/tlx/string/format_si_iec_units.hpp +19 -0
- package/vendor/include/tlx/string/format_si_units.hpp +32 -0
- package/vendor/include/tlx/string/hash_djb2.hpp +87 -0
- package/vendor/include/tlx/string/hash_sdbm.hpp +86 -0
- package/vendor/include/tlx/string/hexdump.hpp +154 -0
- package/vendor/include/tlx/string/index_of.hpp +56 -0
- package/vendor/include/tlx/string/join.hpp +65 -0
- package/vendor/include/tlx/string/join_generic.hpp +89 -0
- package/vendor/include/tlx/string/join_quoted.hpp +46 -0
- package/vendor/include/tlx/string/less_icase.hpp +64 -0
- package/vendor/include/tlx/string/levenshtein.hpp +193 -0
- package/vendor/include/tlx/string/pad.hpp +39 -0
- package/vendor/include/tlx/string/parse_si_iec_units.hpp +46 -0
- package/vendor/include/tlx/string/parse_uri.hpp +66 -0
- package/vendor/include/tlx/string/parse_uri_form_data.hpp +136 -0
- package/vendor/include/tlx/string/replace.hpp +141 -0
- package/vendor/include/tlx/string/split.hpp +170 -0
- package/vendor/include/tlx/string/split_quoted.hpp +49 -0
- package/vendor/include/tlx/string/split_view.hpp +218 -0
- package/vendor/include/tlx/string/split_words.hpp +53 -0
- package/vendor/include/tlx/string/ssprintf.hpp +45 -0
- package/vendor/include/tlx/string/ssprintf_generic.hpp +95 -0
- package/vendor/include/tlx/string/starts_with.hpp +44 -0
- package/vendor/include/tlx/string/to_lower.hpp +47 -0
- package/vendor/include/tlx/string/to_upper.hpp +47 -0
- package/vendor/include/tlx/string/trim.hpp +298 -0
- package/vendor/include/tlx/string/union_words.hpp +33 -0
- package/vendor/include/tlx/string/word_wrap.hpp +35 -0
- package/vendor/include/tlx/string.hpp +68 -0
- package/vendor/include/tlx/thread_barrier_mutex.hpp +109 -0
- package/vendor/include/tlx/thread_barrier_spin.hpp +127 -0
- package/vendor/include/tlx/thread_pool.hpp +151 -0
- package/vendor/include/tlx/timestamp.hpp +23 -0
- package/vendor/include/tlx/unused.hpp +28 -0
- package/vendor/include/tlx/vector_free.hpp +30 -0
- package/vendor/include/tlx/version.hpp +49 -0
- package/vendor/include/ttmath/ttmath.h +2881 -0
- package/vendor/include/ttmath/ttmathbig.h +6111 -0
- package/vendor/include/ttmath/ttmathdec.h +419 -0
- package/vendor/include/ttmath/ttmathint.h +1923 -0
- package/vendor/include/ttmath/ttmathmisc.h +250 -0
- package/vendor/include/ttmath/ttmathobjects.h +812 -0
- package/vendor/include/ttmath/ttmathparser.h +2791 -0
- package/vendor/include/ttmath/ttmaththreads.h +252 -0
- package/vendor/include/ttmath/ttmathtypes.h +707 -0
- package/vendor/include/ttmath/ttmathuint.h +4190 -0
- package/vendor/include/ttmath/ttmathuint_noasm.h +1038 -0
- package/vendor/include/ttmath/ttmathuint_x86.h +1620 -0
- package/vendor/include/ttmath/ttmathuint_x86_64.h +1177 -0
- package/vendor/lib/cmake/tlx/tlx-config.cmake +51 -0
- package/vendor/lib/cmake/tlx/tlx-targets-release.cmake +19 -0
- package/vendor/lib/cmake/tlx/tlx-targets.cmake +106 -0
- package/vendor/lib/cmake/tlx/tlx-version.cmake +11 -0
- package/vendor/lib/libnetworkit.dylib +0 -0
- package/vendor/lib/libtlx.a +0 -0
- package/vendor/lib/pkgconfig/networkit.pc +11 -0
- package/vendor/lib/pkgconfig/tlx.pc +11 -0
package/src/addon.cpp
ADDED
|
@@ -0,0 +1,1253 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* addon.cpp – Node.js N-API bindings for icebug / NetworKit
|
|
3
|
+
*
|
|
4
|
+
* Exposed JS classes:
|
|
5
|
+
* Graph – wraps NetworKit::GraphW (mutable, vector-based adjacency lists)
|
|
6
|
+
* GraphR – wraps NetworKit::GraphR (read-only, Arrow CSR arrays)
|
|
7
|
+
* Betweenness – wraps NetworKit::Betweenness
|
|
8
|
+
* PageRank – wraps NetworKit::PageRank
|
|
9
|
+
* DegreeCentrality – wraps NetworKit::DegreeCentrality
|
|
10
|
+
* ConnectedComponents– wraps NetworKit::ConnectedComponents
|
|
11
|
+
* Louvain – wraps NetworKit::PLM (Parallel Louvain Method)
|
|
12
|
+
* Leiden – wraps NetworKit::ParallelLeiden
|
|
13
|
+
*
|
|
14
|
+
* Exposed JS functions:
|
|
15
|
+
* readMETIS(path) → Graph
|
|
16
|
+
* readEdgeList(path, sep, firstNode, directed, commentPrefix) → Graph
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#include <napi.h>
|
|
20
|
+
|
|
21
|
+
#include <networkit/graph/GraphW.hpp>
|
|
22
|
+
#include <networkit/graph/GraphR.hpp>
|
|
23
|
+
#include <networkit/centrality/Betweenness.hpp>
|
|
24
|
+
#include <networkit/centrality/DegreeCentrality.hpp>
|
|
25
|
+
#include <networkit/centrality/PageRank.hpp>
|
|
26
|
+
#include <networkit/components/ConnectedComponents.hpp>
|
|
27
|
+
#include <networkit/community/PLM.hpp>
|
|
28
|
+
#include <networkit/community/ParallelLeiden.hpp>
|
|
29
|
+
#include <networkit/community/Modularity.hpp>
|
|
30
|
+
#include <networkit/structures/Partition.hpp>
|
|
31
|
+
#include <networkit/io/EdgeListReader.hpp>
|
|
32
|
+
#include <networkit/io/METISGraphReader.hpp>
|
|
33
|
+
|
|
34
|
+
#include <map>
|
|
35
|
+
#include <memory>
|
|
36
|
+
#include <stdexcept>
|
|
37
|
+
#include <string>
|
|
38
|
+
#include <vector>
|
|
39
|
+
|
|
40
|
+
using namespace Napi;
|
|
41
|
+
using namespace NetworKit;
|
|
42
|
+
|
|
43
|
+
// ============================================================================
|
|
44
|
+
// Forward declarations (constructors defined later)
|
|
45
|
+
// ============================================================================
|
|
46
|
+
class GraphWrapper;
|
|
47
|
+
class GraphRWrapper;
|
|
48
|
+
|
|
49
|
+
Napi::FunctionReference g_GraphCtor;
|
|
50
|
+
Napi::FunctionReference g_GraphRCtor;
|
|
51
|
+
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Helpers
|
|
54
|
+
// ============================================================================
|
|
55
|
+
|
|
56
|
+
/** Wrap a C++ exception into a Napi::Error and throw it. */
|
|
57
|
+
static void throwError(Napi::Env env, const std::exception &e) {
|
|
58
|
+
Napi::Error::New(env, e.what()).ThrowAsJavaScriptException();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Convert a JS value to a node (uint64_t). Accepts Number or BigInt. */
|
|
62
|
+
static node jsToNode(const Napi::Value &v) {
|
|
63
|
+
if (v.IsBigInt()) {
|
|
64
|
+
bool lossless = true;
|
|
65
|
+
return v.As<Napi::BigInt>().Uint64Value(&lossless);
|
|
66
|
+
}
|
|
67
|
+
return static_cast<node>(v.As<Napi::Number>().DoubleValue());
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Wrap a node id as a JS Number (safe for ids < 2^53). */
|
|
71
|
+
static Napi::Value nodeToJs(Napi::Env env, node u) {
|
|
72
|
+
return Napi::Number::New(env, static_cast<double>(u));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// GraphWrapper (JS class: Graph)
|
|
77
|
+
// Wraps GraphW – the mutable, vector-based NetworKit graph.
|
|
78
|
+
// ============================================================================
|
|
79
|
+
class GraphWrapper : public Napi::ObjectWrap<GraphWrapper> {
|
|
80
|
+
public:
|
|
81
|
+
static Napi::Object Init(Napi::Env env, Napi::Object exports);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* JS: new Graph(n=0, weighted=false, directed=false)
|
|
85
|
+
*
|
|
86
|
+
* Internal: when info[0].IsExternal() the wrapper takes ownership of an
|
|
87
|
+
* existing GraphW* pointer (used by readMETIS / readEdgeList factories).
|
|
88
|
+
*/
|
|
89
|
+
explicit GraphWrapper(const Napi::CallbackInfo &info)
|
|
90
|
+
: Napi::ObjectWrap<GraphWrapper>(info) {
|
|
91
|
+
if (info.Length() == 1 && info[0].IsExternal()) {
|
|
92
|
+
// Factory path: take ownership of an externally-created GraphW.
|
|
93
|
+
auto *raw = info[0].As<Napi::External<GraphW>>().Data();
|
|
94
|
+
graph_.reset(raw);
|
|
95
|
+
} else {
|
|
96
|
+
count n = 0;
|
|
97
|
+
bool weighted = false;
|
|
98
|
+
bool directed = false;
|
|
99
|
+
if (info.Length() >= 1) n = static_cast<count>(info[0].As<Napi::Number>().DoubleValue());
|
|
100
|
+
if (info.Length() >= 2) weighted = info[1].As<Napi::Boolean>();
|
|
101
|
+
if (info.Length() >= 3) directed = info[2].As<Napi::Boolean>();
|
|
102
|
+
try {
|
|
103
|
+
graph_ = std::make_unique<GraphW>(n, weighted, directed);
|
|
104
|
+
} catch (const std::exception &e) {
|
|
105
|
+
throwError(info.Env(), e);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Access the underlying GraphW (used by algorithm wrappers). */
|
|
111
|
+
GraphW *graph() const { return graph_.get(); }
|
|
112
|
+
/** Access as base Graph& (used by algorithm wrappers). */
|
|
113
|
+
const Graph &baseGraph() const { return *graph_; }
|
|
114
|
+
|
|
115
|
+
private:
|
|
116
|
+
std::unique_ptr<GraphW> graph_;
|
|
117
|
+
|
|
118
|
+
// ---- node / edge counts ----
|
|
119
|
+
|
|
120
|
+
Napi::Value NumberOfNodes(const Napi::CallbackInfo &info) {
|
|
121
|
+
return Napi::Number::New(info.Env(), static_cast<double>(graph_->numberOfNodes()));
|
|
122
|
+
}
|
|
123
|
+
Napi::Value NumberOfEdges(const Napi::CallbackInfo &info) {
|
|
124
|
+
return Napi::Number::New(info.Env(), static_cast<double>(graph_->numberOfEdges()));
|
|
125
|
+
}
|
|
126
|
+
Napi::Value UpperNodeIdBound(const Napi::CallbackInfo &info) {
|
|
127
|
+
return Napi::Number::New(info.Env(), static_cast<double>(graph_->upperNodeIdBound()));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ---- mutation ----
|
|
131
|
+
|
|
132
|
+
Napi::Value AddNode(const Napi::CallbackInfo &info) {
|
|
133
|
+
try {
|
|
134
|
+
node v = graph_->addNode();
|
|
135
|
+
return nodeToJs(info.Env(), v);
|
|
136
|
+
} catch (const std::exception &e) {
|
|
137
|
+
throwError(info.Env(), e);
|
|
138
|
+
return info.Env().Undefined();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
Napi::Value AddEdge(const Napi::CallbackInfo &info) {
|
|
142
|
+
if (info.Length() < 2) {
|
|
143
|
+
Napi::TypeError::New(info.Env(), "addEdge(u, v [, weight])").ThrowAsJavaScriptException();
|
|
144
|
+
return info.Env().Undefined();
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
node u = jsToNode(info[0]);
|
|
148
|
+
node v = jsToNode(info[1]);
|
|
149
|
+
edgeweight w = (info.Length() >= 3) ? info[2].As<Napi::Number>().DoubleValue()
|
|
150
|
+
: defaultEdgeWeight;
|
|
151
|
+
bool ok = graph_->addEdge(u, v, w);
|
|
152
|
+
return Napi::Boolean::New(info.Env(), ok);
|
|
153
|
+
} catch (const std::exception &e) {
|
|
154
|
+
throwError(info.Env(), e);
|
|
155
|
+
return info.Env().Undefined();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
Napi::Value RemoveNode(const Napi::CallbackInfo &info) {
|
|
159
|
+
if (info.Length() < 1) {
|
|
160
|
+
Napi::TypeError::New(info.Env(), "removeNode(u)").ThrowAsJavaScriptException();
|
|
161
|
+
return info.Env().Undefined();
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
graph_->removeNode(jsToNode(info[0]));
|
|
165
|
+
} catch (const std::exception &e) {
|
|
166
|
+
throwError(info.Env(), e);
|
|
167
|
+
}
|
|
168
|
+
return info.Env().Undefined();
|
|
169
|
+
}
|
|
170
|
+
Napi::Value RemoveEdge(const Napi::CallbackInfo &info) {
|
|
171
|
+
if (info.Length() < 2) {
|
|
172
|
+
Napi::TypeError::New(info.Env(), "removeEdge(u, v)").ThrowAsJavaScriptException();
|
|
173
|
+
return info.Env().Undefined();
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
graph_->removeEdge(jsToNode(info[0]), jsToNode(info[1]));
|
|
177
|
+
} catch (const std::exception &e) {
|
|
178
|
+
throwError(info.Env(), e);
|
|
179
|
+
}
|
|
180
|
+
return info.Env().Undefined();
|
|
181
|
+
}
|
|
182
|
+
Napi::Value SetWeight(const Napi::CallbackInfo &info) {
|
|
183
|
+
if (info.Length() < 3) {
|
|
184
|
+
Napi::TypeError::New(info.Env(), "setWeight(u, v, w)").ThrowAsJavaScriptException();
|
|
185
|
+
return info.Env().Undefined();
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
graph_->setWeight(jsToNode(info[0]), jsToNode(info[1]),
|
|
189
|
+
info[2].As<Napi::Number>().DoubleValue());
|
|
190
|
+
} catch (const std::exception &e) {
|
|
191
|
+
throwError(info.Env(), e);
|
|
192
|
+
}
|
|
193
|
+
return info.Env().Undefined();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ---- predicates ----
|
|
197
|
+
|
|
198
|
+
Napi::Value HasNode(const Napi::CallbackInfo &info) {
|
|
199
|
+
if (info.Length() < 1) return Napi::Boolean::New(info.Env(), false);
|
|
200
|
+
return Napi::Boolean::New(info.Env(), graph_->hasNode(jsToNode(info[0])));
|
|
201
|
+
}
|
|
202
|
+
Napi::Value HasEdge(const Napi::CallbackInfo &info) {
|
|
203
|
+
if (info.Length() < 2) return Napi::Boolean::New(info.Env(), false);
|
|
204
|
+
return Napi::Boolean::New(info.Env(),
|
|
205
|
+
graph_->hasEdge(jsToNode(info[0]), jsToNode(info[1])));
|
|
206
|
+
}
|
|
207
|
+
Napi::Value IsWeighted(const Napi::CallbackInfo &info) {
|
|
208
|
+
return Napi::Boolean::New(info.Env(), graph_->isWeighted());
|
|
209
|
+
}
|
|
210
|
+
Napi::Value IsDirected(const Napi::CallbackInfo &info) {
|
|
211
|
+
return Napi::Boolean::New(info.Env(), graph_->isDirected());
|
|
212
|
+
}
|
|
213
|
+
Napi::Value IsEmpty(const Napi::CallbackInfo &info) {
|
|
214
|
+
return Napi::Boolean::New(info.Env(), graph_->isEmpty());
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ---- per-node properties ----
|
|
218
|
+
|
|
219
|
+
Napi::Value Degree(const Napi::CallbackInfo &info) {
|
|
220
|
+
if (info.Length() < 1) {
|
|
221
|
+
Napi::TypeError::New(info.Env(), "degree(u)").ThrowAsJavaScriptException();
|
|
222
|
+
return info.Env().Undefined();
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
return Napi::Number::New(info.Env(),
|
|
226
|
+
static_cast<double>(graph_->degree(jsToNode(info[0]))));
|
|
227
|
+
} catch (const std::exception &e) {
|
|
228
|
+
throwError(info.Env(), e);
|
|
229
|
+
return info.Env().Undefined();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
Napi::Value DegreeIn(const Napi::CallbackInfo &info) {
|
|
233
|
+
if (info.Length() < 1) {
|
|
234
|
+
Napi::TypeError::New(info.Env(), "degreeIn(u)").ThrowAsJavaScriptException();
|
|
235
|
+
return info.Env().Undefined();
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
238
|
+
return Napi::Number::New(info.Env(),
|
|
239
|
+
static_cast<double>(graph_->degreeIn(jsToNode(info[0]))));
|
|
240
|
+
} catch (const std::exception &e) {
|
|
241
|
+
throwError(info.Env(), e);
|
|
242
|
+
return info.Env().Undefined();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
Napi::Value Weight(const Napi::CallbackInfo &info) {
|
|
246
|
+
if (info.Length() < 2) {
|
|
247
|
+
Napi::TypeError::New(info.Env(), "weight(u, v)").ThrowAsJavaScriptException();
|
|
248
|
+
return info.Env().Undefined();
|
|
249
|
+
}
|
|
250
|
+
return Napi::Number::New(
|
|
251
|
+
info.Env(),
|
|
252
|
+
graph_->weight(jsToNode(info[0]), jsToNode(info[1])));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ---- iteration helpers ----
|
|
256
|
+
|
|
257
|
+
/** neighbors(u) → number[] */
|
|
258
|
+
Napi::Value Neighbors(const Napi::CallbackInfo &info) {
|
|
259
|
+
if (info.Length() < 1) {
|
|
260
|
+
Napi::TypeError::New(info.Env(), "neighbors(u)").ThrowAsJavaScriptException();
|
|
261
|
+
return info.Env().Undefined();
|
|
262
|
+
}
|
|
263
|
+
try {
|
|
264
|
+
node u = jsToNode(info[0]);
|
|
265
|
+
Napi::Array result = Napi::Array::New(info.Env());
|
|
266
|
+
uint32_t idx = 0;
|
|
267
|
+
graph_->forNeighborsOf(u, [&](node v) {
|
|
268
|
+
result[idx++] = nodeToJs(info.Env(), v);
|
|
269
|
+
});
|
|
270
|
+
return result;
|
|
271
|
+
} catch (const std::exception &e) {
|
|
272
|
+
throwError(info.Env(), e);
|
|
273
|
+
return info.Env().Undefined();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** nodes() → number[] – all existing node ids */
|
|
278
|
+
Napi::Value Nodes(const Napi::CallbackInfo &info) {
|
|
279
|
+
Napi::Array result = Napi::Array::New(info.Env());
|
|
280
|
+
uint32_t idx = 0;
|
|
281
|
+
graph_->forNodes([&](node u) {
|
|
282
|
+
result[idx++] = nodeToJs(info.Env(), u);
|
|
283
|
+
});
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** edges() → [number, number][] – each entry is [u, v] */
|
|
288
|
+
Napi::Value Edges(const Napi::CallbackInfo &info) {
|
|
289
|
+
Napi::Array result = Napi::Array::New(info.Env());
|
|
290
|
+
uint32_t idx = 0;
|
|
291
|
+
graph_->forEdges([&](node u, node v) {
|
|
292
|
+
Napi::Array pair = Napi::Array::New(info.Env(), 2);
|
|
293
|
+
pair[0u] = nodeToJs(info.Env(), u);
|
|
294
|
+
pair[1u] = nodeToJs(info.Env(), v);
|
|
295
|
+
result[idx++] = pair;
|
|
296
|
+
});
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** weightedEdges() → [number, number, number][] – [u, v, weight] */
|
|
301
|
+
Napi::Value WeightedEdges(const Napi::CallbackInfo &info) {
|
|
302
|
+
Napi::Array result = Napi::Array::New(info.Env());
|
|
303
|
+
uint32_t idx = 0;
|
|
304
|
+
graph_->forEdges([&](node u, node v, edgeweight w) {
|
|
305
|
+
Napi::Array triple = Napi::Array::New(info.Env(), 3);
|
|
306
|
+
triple[0u] = nodeToJs(info.Env(), u);
|
|
307
|
+
triple[1u] = nodeToJs(info.Env(), v);
|
|
308
|
+
triple[2u] = Napi::Number::New(info.Env(), w);
|
|
309
|
+
result[idx++] = triple;
|
|
310
|
+
});
|
|
311
|
+
return result;
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
// ============================================================================
|
|
316
|
+
// GraphRWrapper (JS class: GraphR)
|
|
317
|
+
// Wraps GraphR – read-only CSR-backed graph.
|
|
318
|
+
//
|
|
319
|
+
// Memory strategy
|
|
320
|
+
// ───────────────
|
|
321
|
+
// GraphR stores Arrow arrays that hold raw pointers into the underlying
|
|
322
|
+
// buffers. We need those buffers to stay alive for the lifetime of the C++
|
|
323
|
+
// graph object. The canonical JS source for the data is a BigUint64Array
|
|
324
|
+
// (8 bytes per element, matching NetworKit's node / index = uint64_t).
|
|
325
|
+
//
|
|
326
|
+
// Each BigUint64Array argument is pinned by holding a strong Napi::Reference
|
|
327
|
+
// to its backing ArrayBuffer. The reference count is incremented to 1 in
|
|
328
|
+
// the constructor and is reset (to 0, allowing GC) in the ObjectWrap
|
|
329
|
+
// finaliser, which fires when the JS GraphR object itself is collected.
|
|
330
|
+
// The Arrow Buffer wraps the raw pointer with no ownership (no deleter), so
|
|
331
|
+
// Arrow will never try to free the memory – that duty stays with V8.
|
|
332
|
+
// ============================================================================
|
|
333
|
+
class GraphRWrapper : public Napi::ObjectWrap<GraphRWrapper> {
|
|
334
|
+
public:
|
|
335
|
+
static Napi::Object Init(Napi::Env env, Napi::Object exports);
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* JS: new GraphR(n, directed,
|
|
339
|
+
* outIndices: BigUint64Array, outIndptr: BigUint64Array
|
|
340
|
+
* [, inIndices: BigUint64Array, inIndptr: BigUint64Array])
|
|
341
|
+
*
|
|
342
|
+
* outIndices / outIndptr must be BigUint64Array (uint64 elements).
|
|
343
|
+
* For directed graphs pass inIndices and inIndptr as well.
|
|
344
|
+
*/
|
|
345
|
+
explicit GraphRWrapper(const Napi::CallbackInfo &info)
|
|
346
|
+
: Napi::ObjectWrap<GraphRWrapper>(info) {
|
|
347
|
+
if (info.Length() < 4) {
|
|
348
|
+
Napi::TypeError::New(info.Env(),
|
|
349
|
+
"GraphR(n, directed, outIndices: BigUint64Array, outIndptr: BigUint64Array"
|
|
350
|
+
" [, inIndices: BigUint64Array, inIndptr: BigUint64Array])")
|
|
351
|
+
.ThrowAsJavaScriptException();
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
try {
|
|
355
|
+
count n = static_cast<count>(info[0].As<Napi::Number>().DoubleValue());
|
|
356
|
+
bool directed = info[1].As<Napi::Boolean>();
|
|
357
|
+
|
|
358
|
+
// Pin a BigUint64Array: keep its ArrayBuffer alive and return a
|
|
359
|
+
// zero-copy arrow::UInt64Array wrapping the raw memory.
|
|
360
|
+
auto pinArray = [&](const Napi::Value &val, const char *argName)
|
|
361
|
+
-> std::pair<Napi::Reference<Napi::ArrayBuffer>,
|
|
362
|
+
std::shared_ptr<arrow::UInt64Array>>
|
|
363
|
+
{
|
|
364
|
+
if (!val.IsTypedArray()) {
|
|
365
|
+
throw std::runtime_error(
|
|
366
|
+
std::string(argName) + " must be a BigUint64Array");
|
|
367
|
+
}
|
|
368
|
+
auto ta = val.As<Napi::TypedArray>();
|
|
369
|
+
if (ta.TypedArrayType() != napi_biguint64_array) {
|
|
370
|
+
throw std::runtime_error(
|
|
371
|
+
std::string(argName) + " must be a BigUint64Array (got wrong TypedArray type)");
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Pin the backing ArrayBuffer so V8 won't GC it while graph_ lives.
|
|
375
|
+
Napi::ArrayBuffer ab = ta.ArrayBuffer();
|
|
376
|
+
auto ref = Napi::Reference<Napi::ArrayBuffer>::New(ab, 1);
|
|
377
|
+
|
|
378
|
+
// Wrap the raw bytes as an Arrow buffer – zero copy, no ownership.
|
|
379
|
+
const uint8_t *raw = static_cast<const uint8_t *>(ab.Data())
|
|
380
|
+
+ ta.ByteOffset();
|
|
381
|
+
int64_t byteLen = static_cast<int64_t>(ta.ElementLength() * sizeof(uint64_t));
|
|
382
|
+
auto arrowBuf = std::make_shared<arrow::Buffer>(raw, byteLen);
|
|
383
|
+
auto arrowArr = std::make_shared<arrow::UInt64Array>(
|
|
384
|
+
static_cast<int64_t>(ta.ElementLength()), arrowBuf);
|
|
385
|
+
|
|
386
|
+
return {std::move(ref), std::move(arrowArr)};
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
auto [outIdxRef, outIdxArr] = pinArray(info[2], "outIndices");
|
|
390
|
+
auto [outPtrRef, outPtrArr] = pinArray(info[3], "outIndptr");
|
|
391
|
+
outIdxRef_ = std::move(outIdxRef);
|
|
392
|
+
outPtrRef_ = std::move(outPtrRef);
|
|
393
|
+
|
|
394
|
+
std::shared_ptr<arrow::UInt64Array> inIdxArr, inPtrArr;
|
|
395
|
+
if (info.Length() >= 6
|
|
396
|
+
&& !info[4].IsUndefined() && !info[4].IsNull()
|
|
397
|
+
&& !info[5].IsUndefined() && !info[5].IsNull()) {
|
|
398
|
+
auto [inIdxRef, inIdxArr_] = pinArray(info[4], "inIndices");
|
|
399
|
+
auto [inPtrRef, inPtrArr_] = pinArray(info[5], "inIndptr");
|
|
400
|
+
inIdxRef_ = std::move(inIdxRef);
|
|
401
|
+
inPtrRef_ = std::move(inPtrRef);
|
|
402
|
+
inIdxArr = std::move(inIdxArr_);
|
|
403
|
+
inPtrArr = std::move(inPtrArr_);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
graph_ = std::make_unique<GraphR>(n, directed,
|
|
407
|
+
outIdxArr, outPtrArr,
|
|
408
|
+
inIdxArr, inPtrArr);
|
|
409
|
+
} catch (const std::exception &e) {
|
|
410
|
+
throwError(info.Env(), e);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const Graph &baseGraph() const { return *graph_; }
|
|
415
|
+
|
|
416
|
+
private:
|
|
417
|
+
std::unique_ptr<GraphR> graph_;
|
|
418
|
+
|
|
419
|
+
// Pinned JS ArrayBuffers – prevent V8 from collecting the backing memory
|
|
420
|
+
// while graph_ (and its Arrow arrays) are still alive.
|
|
421
|
+
Napi::Reference<Napi::ArrayBuffer> outIdxRef_;
|
|
422
|
+
Napi::Reference<Napi::ArrayBuffer> outPtrRef_;
|
|
423
|
+
Napi::Reference<Napi::ArrayBuffer> inIdxRef_;
|
|
424
|
+
Napi::Reference<Napi::ArrayBuffer> inPtrRef_;
|
|
425
|
+
|
|
426
|
+
// ---- counts ----
|
|
427
|
+
Napi::Value NumberOfNodes(const Napi::CallbackInfo &info) {
|
|
428
|
+
return Napi::Number::New(info.Env(), static_cast<double>(graph_->numberOfNodes()));
|
|
429
|
+
}
|
|
430
|
+
Napi::Value NumberOfEdges(const Napi::CallbackInfo &info) {
|
|
431
|
+
return Napi::Number::New(info.Env(), static_cast<double>(graph_->numberOfEdges()));
|
|
432
|
+
}
|
|
433
|
+
Napi::Value UpperNodeIdBound(const Napi::CallbackInfo &info) {
|
|
434
|
+
return Napi::Number::New(info.Env(), static_cast<double>(graph_->upperNodeIdBound()));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// ---- predicates ----
|
|
438
|
+
Napi::Value HasNode(const Napi::CallbackInfo &info) {
|
|
439
|
+
if (info.Length() < 1) return Napi::Boolean::New(info.Env(), false);
|
|
440
|
+
return Napi::Boolean::New(info.Env(), graph_->hasNode(jsToNode(info[0])));
|
|
441
|
+
}
|
|
442
|
+
Napi::Value HasEdge(const Napi::CallbackInfo &info) {
|
|
443
|
+
if (info.Length() < 2) return Napi::Boolean::New(info.Env(), false);
|
|
444
|
+
return Napi::Boolean::New(info.Env(),
|
|
445
|
+
graph_->hasEdge(jsToNode(info[0]), jsToNode(info[1])));
|
|
446
|
+
}
|
|
447
|
+
Napi::Value IsWeighted(const Napi::CallbackInfo &info) {
|
|
448
|
+
return Napi::Boolean::New(info.Env(), graph_->isWeighted());
|
|
449
|
+
}
|
|
450
|
+
Napi::Value IsDirected(const Napi::CallbackInfo &info) {
|
|
451
|
+
return Napi::Boolean::New(info.Env(), graph_->isDirected());
|
|
452
|
+
}
|
|
453
|
+
Napi::Value IsEmpty(const Napi::CallbackInfo &info) {
|
|
454
|
+
return Napi::Boolean::New(info.Env(), graph_->isEmpty());
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// ---- per-node ----
|
|
458
|
+
Napi::Value Degree(const Napi::CallbackInfo &info) {
|
|
459
|
+
if (info.Length() < 1) {
|
|
460
|
+
Napi::TypeError::New(info.Env(), "degree(u)").ThrowAsJavaScriptException();
|
|
461
|
+
return info.Env().Undefined();
|
|
462
|
+
}
|
|
463
|
+
try {
|
|
464
|
+
return Napi::Number::New(info.Env(),
|
|
465
|
+
static_cast<double>(graph_->degree(jsToNode(info[0]))));
|
|
466
|
+
} catch (const std::exception &e) {
|
|
467
|
+
throwError(info.Env(), e);
|
|
468
|
+
return info.Env().Undefined();
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
Napi::Value DegreeIn(const Napi::CallbackInfo &info) {
|
|
472
|
+
if (info.Length() < 1) {
|
|
473
|
+
Napi::TypeError::New(info.Env(), "degreeIn(u)").ThrowAsJavaScriptException();
|
|
474
|
+
return info.Env().Undefined();
|
|
475
|
+
}
|
|
476
|
+
try {
|
|
477
|
+
return Napi::Number::New(info.Env(),
|
|
478
|
+
static_cast<double>(graph_->degreeIn(jsToNode(info[0]))));
|
|
479
|
+
} catch (const std::exception &e) {
|
|
480
|
+
throwError(info.Env(), e);
|
|
481
|
+
return info.Env().Undefined();
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
Napi::Value Weight(const Napi::CallbackInfo &info) {
|
|
485
|
+
if (info.Length() < 2) {
|
|
486
|
+
Napi::TypeError::New(info.Env(), "weight(u, v)").ThrowAsJavaScriptException();
|
|
487
|
+
return info.Env().Undefined();
|
|
488
|
+
}
|
|
489
|
+
return Napi::Number::New(
|
|
490
|
+
info.Env(),
|
|
491
|
+
graph_->weight(jsToNode(info[0]), jsToNode(info[1])));
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// ---- iteration ----
|
|
495
|
+
Napi::Value Neighbors(const Napi::CallbackInfo &info) {
|
|
496
|
+
if (info.Length() < 1) {
|
|
497
|
+
Napi::TypeError::New(info.Env(), "neighbors(u)").ThrowAsJavaScriptException();
|
|
498
|
+
return info.Env().Undefined();
|
|
499
|
+
}
|
|
500
|
+
try {
|
|
501
|
+
node u = jsToNode(info[0]);
|
|
502
|
+
Napi::Array result = Napi::Array::New(info.Env());
|
|
503
|
+
uint32_t idx = 0;
|
|
504
|
+
graph_->forNeighborsOf(u, [&](node v) {
|
|
505
|
+
result[idx++] = nodeToJs(info.Env(), v);
|
|
506
|
+
});
|
|
507
|
+
return result;
|
|
508
|
+
} catch (const std::exception &e) {
|
|
509
|
+
throwError(info.Env(), e);
|
|
510
|
+
return info.Env().Undefined();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
Napi::Value Nodes(const Napi::CallbackInfo &info) {
|
|
514
|
+
Napi::Array result = Napi::Array::New(info.Env());
|
|
515
|
+
uint32_t idx = 0;
|
|
516
|
+
graph_->forNodes([&](node u) {
|
|
517
|
+
result[idx++] = nodeToJs(info.Env(), u);
|
|
518
|
+
});
|
|
519
|
+
return result;
|
|
520
|
+
}
|
|
521
|
+
Napi::Value Edges(const Napi::CallbackInfo &info) {
|
|
522
|
+
Napi::Array result = Napi::Array::New(info.Env());
|
|
523
|
+
uint32_t idx = 0;
|
|
524
|
+
graph_->forEdges([&](node u, node v) {
|
|
525
|
+
Napi::Array pair = Napi::Array::New(info.Env(), 2);
|
|
526
|
+
pair[0u] = nodeToJs(info.Env(), u);
|
|
527
|
+
pair[1u] = nodeToJs(info.Env(), v);
|
|
528
|
+
result[idx++] = pair;
|
|
529
|
+
});
|
|
530
|
+
return result;
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
// ============================================================================
|
|
535
|
+
// Init registration (must come after class bodies since we reference members)
|
|
536
|
+
// ============================================================================
|
|
537
|
+
|
|
538
|
+
Napi::Object GraphWrapper::Init(Napi::Env env, Napi::Object exports) {
|
|
539
|
+
Napi::Function func = DefineClass(env, "Graph", {
|
|
540
|
+
InstanceMethod("numberOfNodes", &GraphWrapper::NumberOfNodes),
|
|
541
|
+
InstanceMethod("numberOfEdges", &GraphWrapper::NumberOfEdges),
|
|
542
|
+
InstanceMethod("upperNodeIdBound",&GraphWrapper::UpperNodeIdBound),
|
|
543
|
+
InstanceMethod("addNode", &GraphWrapper::AddNode),
|
|
544
|
+
InstanceMethod("addEdge", &GraphWrapper::AddEdge),
|
|
545
|
+
InstanceMethod("removeNode", &GraphWrapper::RemoveNode),
|
|
546
|
+
InstanceMethod("removeEdge", &GraphWrapper::RemoveEdge),
|
|
547
|
+
InstanceMethod("setWeight", &GraphWrapper::SetWeight),
|
|
548
|
+
InstanceMethod("hasNode", &GraphWrapper::HasNode),
|
|
549
|
+
InstanceMethod("hasEdge", &GraphWrapper::HasEdge),
|
|
550
|
+
InstanceMethod("isWeighted", &GraphWrapper::IsWeighted),
|
|
551
|
+
InstanceMethod("isDirected", &GraphWrapper::IsDirected),
|
|
552
|
+
InstanceMethod("isEmpty", &GraphWrapper::IsEmpty),
|
|
553
|
+
InstanceMethod("degree", &GraphWrapper::Degree),
|
|
554
|
+
InstanceMethod("degreeIn", &GraphWrapper::DegreeIn),
|
|
555
|
+
InstanceMethod("weight", &GraphWrapper::Weight),
|
|
556
|
+
InstanceMethod("neighbors", &GraphWrapper::Neighbors),
|
|
557
|
+
InstanceMethod("nodes", &GraphWrapper::Nodes),
|
|
558
|
+
InstanceMethod("edges", &GraphWrapper::Edges),
|
|
559
|
+
InstanceMethod("weightedEdges", &GraphWrapper::WeightedEdges),
|
|
560
|
+
});
|
|
561
|
+
g_GraphCtor = Napi::Persistent(func);
|
|
562
|
+
g_GraphCtor.SuppressDestruct();
|
|
563
|
+
exports.Set("Graph", func);
|
|
564
|
+
return exports;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
Napi::Object GraphRWrapper::Init(Napi::Env env, Napi::Object exports) {
|
|
568
|
+
Napi::Function func = DefineClass(env, "GraphR", {
|
|
569
|
+
InstanceMethod("numberOfNodes", &GraphRWrapper::NumberOfNodes),
|
|
570
|
+
InstanceMethod("numberOfEdges", &GraphRWrapper::NumberOfEdges),
|
|
571
|
+
InstanceMethod("upperNodeIdBound",&GraphRWrapper::UpperNodeIdBound),
|
|
572
|
+
InstanceMethod("hasNode", &GraphRWrapper::HasNode),
|
|
573
|
+
InstanceMethod("hasEdge", &GraphRWrapper::HasEdge),
|
|
574
|
+
InstanceMethod("isWeighted", &GraphRWrapper::IsWeighted),
|
|
575
|
+
InstanceMethod("isDirected", &GraphRWrapper::IsDirected),
|
|
576
|
+
InstanceMethod("isEmpty", &GraphRWrapper::IsEmpty),
|
|
577
|
+
InstanceMethod("degree", &GraphRWrapper::Degree),
|
|
578
|
+
InstanceMethod("degreeIn", &GraphRWrapper::DegreeIn),
|
|
579
|
+
InstanceMethod("weight", &GraphRWrapper::Weight),
|
|
580
|
+
InstanceMethod("neighbors", &GraphRWrapper::Neighbors),
|
|
581
|
+
InstanceMethod("nodes", &GraphRWrapper::Nodes),
|
|
582
|
+
InstanceMethod("edges", &GraphRWrapper::Edges),
|
|
583
|
+
});
|
|
584
|
+
g_GraphRCtor = Napi::Persistent(func);
|
|
585
|
+
g_GraphRCtor.SuppressDestruct();
|
|
586
|
+
exports.Set("GraphR", func);
|
|
587
|
+
return exports;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// ============================================================================
|
|
591
|
+
// Helper: extract const Graph& from a JS object (Graph or GraphR).
|
|
592
|
+
// ============================================================================
|
|
593
|
+
static const Graph &extractGraph(const Napi::Value &val) {
|
|
594
|
+
if (!val.IsObject())
|
|
595
|
+
throw std::runtime_error("Expected a Graph or GraphR instance");
|
|
596
|
+
Napi::Object obj = val.As<Napi::Object>();
|
|
597
|
+
if (obj.InstanceOf(g_GraphCtor.Value()))
|
|
598
|
+
return GraphWrapper::Unwrap(obj)->baseGraph();
|
|
599
|
+
if (obj.InstanceOf(g_GraphRCtor.Value()))
|
|
600
|
+
return GraphRWrapper::Unwrap(obj)->baseGraph();
|
|
601
|
+
throw std::runtime_error("Expected a Graph or GraphR instance");
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// ============================================================================
|
|
605
|
+
// Macro to generate the common Centrality wrapper boilerplate:
|
|
606
|
+
// scores() → Float64Array
|
|
607
|
+
// score(v) → number
|
|
608
|
+
// ranking() → [{node, score}]
|
|
609
|
+
// hasFinished() → boolean
|
|
610
|
+
// ============================================================================
|
|
611
|
+
#define CENTRALITY_COMMON_METHODS(AlgoClass) \
|
|
612
|
+
Napi::Value Run(const Napi::CallbackInfo &info) { \
|
|
613
|
+
try { algo_->run(); } \
|
|
614
|
+
catch (const std::exception &e) { throwError(info.Env(), e); } \
|
|
615
|
+
return info.Env().Undefined(); \
|
|
616
|
+
} \
|
|
617
|
+
Napi::Value Scores(const Napi::CallbackInfo &info) { \
|
|
618
|
+
try { \
|
|
619
|
+
algo_->assureFinished(); \
|
|
620
|
+
const auto &s = algo_->scores(); \
|
|
621
|
+
auto buf = Napi::ArrayBuffer::New(info.Env(), \
|
|
622
|
+
s.size() * sizeof(double)); \
|
|
623
|
+
std::memcpy(buf.Data(), s.data(), s.size() * sizeof(double)); \
|
|
624
|
+
return Napi::Float64Array::New(info.Env(), s.size(), buf, 0); \
|
|
625
|
+
} catch (const std::exception &e) { \
|
|
626
|
+
throwError(info.Env(), e); \
|
|
627
|
+
return info.Env().Undefined(); \
|
|
628
|
+
} \
|
|
629
|
+
} \
|
|
630
|
+
Napi::Value Score(const Napi::CallbackInfo &info) { \
|
|
631
|
+
if (info.Length() < 1) { \
|
|
632
|
+
Napi::TypeError::New(info.Env(), "score(v)") \
|
|
633
|
+
.ThrowAsJavaScriptException(); \
|
|
634
|
+
return info.Env().Undefined(); \
|
|
635
|
+
} \
|
|
636
|
+
try { \
|
|
637
|
+
return Napi::Number::New(info.Env(), \
|
|
638
|
+
algo_->score(jsToNode(info[0]))); \
|
|
639
|
+
} catch (const std::exception &e) { \
|
|
640
|
+
throwError(info.Env(), e); \
|
|
641
|
+
return info.Env().Undefined(); \
|
|
642
|
+
} \
|
|
643
|
+
} \
|
|
644
|
+
Napi::Value Ranking(const Napi::CallbackInfo &info) { \
|
|
645
|
+
try { \
|
|
646
|
+
auto ranking = algo_->ranking(); \
|
|
647
|
+
Napi::Array arr = Napi::Array::New(info.Env(), ranking.size()); \
|
|
648
|
+
for (uint32_t i = 0; i < (uint32_t)ranking.size(); ++i) { \
|
|
649
|
+
Napi::Object entry = Napi::Object::New(info.Env()); \
|
|
650
|
+
entry.Set("node", nodeToJs(info.Env(), ranking[i].first)); \
|
|
651
|
+
entry.Set("score", Napi::Number::New(info.Env(), \
|
|
652
|
+
ranking[i].second)); \
|
|
653
|
+
arr[i] = entry; \
|
|
654
|
+
} \
|
|
655
|
+
return arr; \
|
|
656
|
+
} catch (const std::exception &e) { \
|
|
657
|
+
throwError(info.Env(), e); \
|
|
658
|
+
return info.Env().Undefined(); \
|
|
659
|
+
} \
|
|
660
|
+
} \
|
|
661
|
+
Napi::Value HasFinished(const Napi::CallbackInfo &info) { \
|
|
662
|
+
return Napi::Boolean::New(info.Env(), algo_->hasFinished()); \
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// ============================================================================
|
|
666
|
+
// BetweennessWrapper (JS class: Betweenness)
|
|
667
|
+
// ============================================================================
|
|
668
|
+
class BetweennessWrapper : public Napi::ObjectWrap<BetweennessWrapper> {
|
|
669
|
+
public:
|
|
670
|
+
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
671
|
+
Napi::Function func = DefineClass(env, "Betweenness", {
|
|
672
|
+
InstanceMethod("run", &BetweennessWrapper::Run),
|
|
673
|
+
InstanceMethod("scores", &BetweennessWrapper::Scores),
|
|
674
|
+
InstanceMethod("score", &BetweennessWrapper::Score),
|
|
675
|
+
InstanceMethod("ranking", &BetweennessWrapper::Ranking),
|
|
676
|
+
InstanceMethod("hasFinished", &BetweennessWrapper::HasFinished),
|
|
677
|
+
InstanceMethod("maximum", &BetweennessWrapper::Maximum),
|
|
678
|
+
});
|
|
679
|
+
exports.Set("Betweenness", func);
|
|
680
|
+
return exports;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* JS: new Betweenness(graph, normalized=false, computeEdgeCentrality=false)
|
|
685
|
+
*/
|
|
686
|
+
explicit BetweennessWrapper(const Napi::CallbackInfo &info)
|
|
687
|
+
: Napi::ObjectWrap<BetweennessWrapper>(info) {
|
|
688
|
+
if (info.Length() < 1) {
|
|
689
|
+
Napi::TypeError::New(info.Env(), "Betweenness(graph [, normalized, computeEdgeCentrality])")
|
|
690
|
+
.ThrowAsJavaScriptException();
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
try {
|
|
694
|
+
bool normalized = info.Length() >= 2 && info[1].As<Napi::Boolean>();
|
|
695
|
+
bool computeEdgeCentrality= info.Length() >= 3 && info[2].As<Napi::Boolean>();
|
|
696
|
+
graphRef_ = Napi::Persistent(info[0].As<Napi::Object>());
|
|
697
|
+
const Graph &G = extractGraph(info[0]);
|
|
698
|
+
algo_ = std::make_unique<Betweenness>(G, normalized, computeEdgeCentrality);
|
|
699
|
+
} catch (const std::exception &e) {
|
|
700
|
+
throwError(info.Env(), e);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
private:
|
|
705
|
+
Napi::ObjectReference graphRef_;
|
|
706
|
+
std::unique_ptr<Betweenness> algo_;
|
|
707
|
+
|
|
708
|
+
CENTRALITY_COMMON_METHODS(Betweenness)
|
|
709
|
+
|
|
710
|
+
Napi::Value Maximum(const Napi::CallbackInfo &info) {
|
|
711
|
+
try {
|
|
712
|
+
return Napi::Number::New(info.Env(), algo_->maximum());
|
|
713
|
+
} catch (const std::exception &e) {
|
|
714
|
+
throwError(info.Env(), e);
|
|
715
|
+
return info.Env().Undefined();
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
// ============================================================================
|
|
721
|
+
// PageRankWrapper (JS class: PageRank)
|
|
722
|
+
// ============================================================================
|
|
723
|
+
class PageRankWrapper : public Napi::ObjectWrap<PageRankWrapper> {
|
|
724
|
+
public:
|
|
725
|
+
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
726
|
+
Napi::Function func = DefineClass(env, "PageRank", {
|
|
727
|
+
InstanceMethod("run", &PageRankWrapper::Run),
|
|
728
|
+
InstanceMethod("scores", &PageRankWrapper::Scores),
|
|
729
|
+
InstanceMethod("score", &PageRankWrapper::Score),
|
|
730
|
+
InstanceMethod("ranking", &PageRankWrapper::Ranking),
|
|
731
|
+
InstanceMethod("hasFinished", &PageRankWrapper::HasFinished),
|
|
732
|
+
InstanceMethod("numberOfIterations",&PageRankWrapper::NumberOfIterations),
|
|
733
|
+
});
|
|
734
|
+
exports.Set("PageRank", func);
|
|
735
|
+
return exports;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* JS: new PageRank(graph, damp=0.85, tol=1e-8, normalized=false)
|
|
740
|
+
*/
|
|
741
|
+
explicit PageRankWrapper(const Napi::CallbackInfo &info)
|
|
742
|
+
: Napi::ObjectWrap<PageRankWrapper>(info) {
|
|
743
|
+
if (info.Length() < 1) {
|
|
744
|
+
Napi::TypeError::New(info.Env(), "PageRank(graph [, damp, tol, normalized])")
|
|
745
|
+
.ThrowAsJavaScriptException();
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
try {
|
|
749
|
+
double damp = info.Length() >= 2 ? info[1].As<Napi::Number>().DoubleValue() : 0.85;
|
|
750
|
+
double tol = info.Length() >= 3 ? info[2].As<Napi::Number>().DoubleValue() : 1e-8;
|
|
751
|
+
bool normalized = info.Length() >= 4 && info[3].As<Napi::Boolean>();
|
|
752
|
+
graphRef_ = Napi::Persistent(info[0].As<Napi::Object>());
|
|
753
|
+
const Graph &G = extractGraph(info[0]);
|
|
754
|
+
algo_ = std::make_unique<PageRank>(G, damp, tol, normalized);
|
|
755
|
+
} catch (const std::exception &e) {
|
|
756
|
+
throwError(info.Env(), e);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
private:
|
|
761
|
+
Napi::ObjectReference graphRef_;
|
|
762
|
+
std::unique_ptr<PageRank> algo_;
|
|
763
|
+
|
|
764
|
+
CENTRALITY_COMMON_METHODS(PageRank)
|
|
765
|
+
|
|
766
|
+
Napi::Value NumberOfIterations(const Napi::CallbackInfo &info) {
|
|
767
|
+
try {
|
|
768
|
+
return Napi::Number::New(info.Env(),
|
|
769
|
+
static_cast<double>(algo_->numberOfIterations()));
|
|
770
|
+
} catch (const std::exception &e) {
|
|
771
|
+
throwError(info.Env(), e);
|
|
772
|
+
return info.Env().Undefined();
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
// ============================================================================
|
|
778
|
+
// DegreeCentralityWrapper (JS class: DegreeCentrality)
|
|
779
|
+
// ============================================================================
|
|
780
|
+
class DegreeCentralityWrapper : public Napi::ObjectWrap<DegreeCentralityWrapper> {
|
|
781
|
+
public:
|
|
782
|
+
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
783
|
+
Napi::Function func = DefineClass(env, "DegreeCentrality", {
|
|
784
|
+
InstanceMethod("run", &DegreeCentralityWrapper::Run),
|
|
785
|
+
InstanceMethod("scores", &DegreeCentralityWrapper::Scores),
|
|
786
|
+
InstanceMethod("score", &DegreeCentralityWrapper::Score),
|
|
787
|
+
InstanceMethod("ranking", &DegreeCentralityWrapper::Ranking),
|
|
788
|
+
InstanceMethod("hasFinished", &DegreeCentralityWrapper::HasFinished),
|
|
789
|
+
});
|
|
790
|
+
exports.Set("DegreeCentrality", func);
|
|
791
|
+
return exports;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* JS: new DegreeCentrality(graph, normalized=false, outDeg=true, ignoreSelfLoops=true)
|
|
796
|
+
*/
|
|
797
|
+
explicit DegreeCentralityWrapper(const Napi::CallbackInfo &info)
|
|
798
|
+
: Napi::ObjectWrap<DegreeCentralityWrapper>(info) {
|
|
799
|
+
if (info.Length() < 1) {
|
|
800
|
+
Napi::TypeError::New(info.Env(),
|
|
801
|
+
"DegreeCentrality(graph [, normalized, outDeg, ignoreSelfLoops])")
|
|
802
|
+
.ThrowAsJavaScriptException();
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
try {
|
|
806
|
+
bool normalized = info.Length() >= 2 && info[1].As<Napi::Boolean>();
|
|
807
|
+
bool outDeg = info.Length() >= 3 ? (bool)info[2].As<Napi::Boolean>() : true;
|
|
808
|
+
bool ignoreSelfLoops = info.Length() >= 4 ? (bool)info[3].As<Napi::Boolean>() : true;
|
|
809
|
+
graphRef_ = Napi::Persistent(info[0].As<Napi::Object>());
|
|
810
|
+
const Graph &G = extractGraph(info[0]);
|
|
811
|
+
algo_ = std::make_unique<DegreeCentrality>(G, normalized, outDeg, ignoreSelfLoops);
|
|
812
|
+
} catch (const std::exception &e) {
|
|
813
|
+
throwError(info.Env(), e);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
private:
|
|
818
|
+
Napi::ObjectReference graphRef_;
|
|
819
|
+
std::unique_ptr<DegreeCentrality> algo_;
|
|
820
|
+
|
|
821
|
+
CENTRALITY_COMMON_METHODS(DegreeCentrality)
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
// ============================================================================
|
|
825
|
+
// ConnectedComponentsWrapper (JS class: ConnectedComponents)
|
|
826
|
+
// ============================================================================
|
|
827
|
+
class ConnectedComponentsWrapper : public Napi::ObjectWrap<ConnectedComponentsWrapper> {
|
|
828
|
+
public:
|
|
829
|
+
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
830
|
+
Napi::Function func = DefineClass(env, "ConnectedComponents", {
|
|
831
|
+
InstanceMethod("run", &ConnectedComponentsWrapper::Run),
|
|
832
|
+
InstanceMethod("hasFinished", &ConnectedComponentsWrapper::HasFinished),
|
|
833
|
+
InstanceMethod("numberOfComponents", &ConnectedComponentsWrapper::NumberOfComponents),
|
|
834
|
+
InstanceMethod("componentOfNode", &ConnectedComponentsWrapper::ComponentOfNode),
|
|
835
|
+
InstanceMethod("getComponents", &ConnectedComponentsWrapper::GetComponents),
|
|
836
|
+
InstanceMethod("getComponentSizes", &ConnectedComponentsWrapper::GetComponentSizes),
|
|
837
|
+
});
|
|
838
|
+
exports.Set("ConnectedComponents", func);
|
|
839
|
+
return exports;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/** JS: new ConnectedComponents(graph) */
|
|
843
|
+
explicit ConnectedComponentsWrapper(const Napi::CallbackInfo &info)
|
|
844
|
+
: Napi::ObjectWrap<ConnectedComponentsWrapper>(info) {
|
|
845
|
+
if (info.Length() < 1) {
|
|
846
|
+
Napi::TypeError::New(info.Env(), "ConnectedComponents(graph)")
|
|
847
|
+
.ThrowAsJavaScriptException();
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
try {
|
|
851
|
+
graphRef_ = Napi::Persistent(info[0].As<Napi::Object>());
|
|
852
|
+
const Graph &G = extractGraph(info[0]);
|
|
853
|
+
algo_ = std::make_unique<ConnectedComponents>(G);
|
|
854
|
+
} catch (const std::exception &e) {
|
|
855
|
+
throwError(info.Env(), e);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
private:
|
|
860
|
+
Napi::ObjectReference graphRef_;
|
|
861
|
+
std::unique_ptr<ConnectedComponents> algo_;
|
|
862
|
+
|
|
863
|
+
Napi::Value Run(const Napi::CallbackInfo &info) {
|
|
864
|
+
try { algo_->run(); }
|
|
865
|
+
catch (const std::exception &e) { throwError(info.Env(), e); }
|
|
866
|
+
return info.Env().Undefined();
|
|
867
|
+
}
|
|
868
|
+
Napi::Value HasFinished(const Napi::CallbackInfo &info) {
|
|
869
|
+
return Napi::Boolean::New(info.Env(), algo_->hasFinished());
|
|
870
|
+
}
|
|
871
|
+
Napi::Value NumberOfComponents(const Napi::CallbackInfo &info) {
|
|
872
|
+
try {
|
|
873
|
+
return Napi::Number::New(info.Env(),
|
|
874
|
+
static_cast<double>(algo_->numberOfComponents()));
|
|
875
|
+
} catch (const std::exception &e) {
|
|
876
|
+
throwError(info.Env(), e);
|
|
877
|
+
return info.Env().Undefined();
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
Napi::Value ComponentOfNode(const Napi::CallbackInfo &info) {
|
|
881
|
+
if (info.Length() < 1) {
|
|
882
|
+
Napi::TypeError::New(info.Env(), "componentOfNode(u)")
|
|
883
|
+
.ThrowAsJavaScriptException();
|
|
884
|
+
return info.Env().Undefined();
|
|
885
|
+
}
|
|
886
|
+
try {
|
|
887
|
+
return Napi::Number::New(info.Env(),
|
|
888
|
+
static_cast<double>(algo_->componentOfNode(jsToNode(info[0]))));
|
|
889
|
+
} catch (const std::exception &e) {
|
|
890
|
+
throwError(info.Env(), e);
|
|
891
|
+
return info.Env().Undefined();
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
/** Returns array of arrays: [[node, ...], [node, ...], ...] */
|
|
895
|
+
Napi::Value GetComponents(const Napi::CallbackInfo &info) {
|
|
896
|
+
try {
|
|
897
|
+
auto comps = algo_->getComponents();
|
|
898
|
+
Napi::Array outer = Napi::Array::New(info.Env(), comps.size());
|
|
899
|
+
for (uint32_t ci = 0; ci < (uint32_t)comps.size(); ++ci) {
|
|
900
|
+
Napi::Array inner = Napi::Array::New(info.Env(), comps[ci].size());
|
|
901
|
+
for (uint32_t ni = 0; ni < (uint32_t)comps[ci].size(); ++ni)
|
|
902
|
+
inner[ni] = nodeToJs(info.Env(), comps[ci][ni]);
|
|
903
|
+
outer[ci] = inner;
|
|
904
|
+
}
|
|
905
|
+
return outer;
|
|
906
|
+
} catch (const std::exception &e) {
|
|
907
|
+
throwError(info.Env(), e);
|
|
908
|
+
return info.Env().Undefined();
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
/** Returns object: { componentId: size, ... } */
|
|
912
|
+
Napi::Value GetComponentSizes(const Napi::CallbackInfo &info) {
|
|
913
|
+
try {
|
|
914
|
+
auto sizes = algo_->getComponentSizes();
|
|
915
|
+
Napi::Object obj = Napi::Object::New(info.Env());
|
|
916
|
+
for (auto &kv : sizes)
|
|
917
|
+
obj.Set(std::to_string(kv.first),
|
|
918
|
+
Napi::Number::New(info.Env(), static_cast<double>(kv.second)));
|
|
919
|
+
return obj;
|
|
920
|
+
} catch (const std::exception &e) {
|
|
921
|
+
throwError(info.Env(), e);
|
|
922
|
+
return info.Env().Undefined();
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
// ============================================================================
|
|
928
|
+
// Macro: common methods shared by Louvain and Leiden wrappers.
|
|
929
|
+
//
|
|
930
|
+
// Requires the host class to have members:
|
|
931
|
+
// std::unique_ptr<AlgoType> algo_
|
|
932
|
+
// const Graph *graphPtr_
|
|
933
|
+
// ============================================================================
|
|
934
|
+
#define CLUSTERING_COMMON_METHODS() \
|
|
935
|
+
Napi::Value Run(const Napi::CallbackInfo &info) { \
|
|
936
|
+
try { algo_->run(); } \
|
|
937
|
+
catch (const std::exception &e) { throwError(info.Env(), e); } \
|
|
938
|
+
return info.Env().Undefined(); \
|
|
939
|
+
} \
|
|
940
|
+
Napi::Value HasFinished(const Napi::CallbackInfo &info) { \
|
|
941
|
+
return Napi::Boolean::New(info.Env(), algo_->hasFinished()); \
|
|
942
|
+
} \
|
|
943
|
+
Napi::Value NumberOfCommunities(const Napi::CallbackInfo &info) { \
|
|
944
|
+
try { \
|
|
945
|
+
algo_->assureFinished(); \
|
|
946
|
+
return Napi::Number::New(info.Env(), \
|
|
947
|
+
static_cast<double>(algo_->getPartition().numberOfSubsets())); \
|
|
948
|
+
} catch (const std::exception &e) { \
|
|
949
|
+
throwError(info.Env(), e); \
|
|
950
|
+
return info.Env().Undefined(); \
|
|
951
|
+
} \
|
|
952
|
+
} \
|
|
953
|
+
Napi::Value CommunityOfNode(const Napi::CallbackInfo &info) { \
|
|
954
|
+
if (info.Length() < 1) { \
|
|
955
|
+
Napi::TypeError::New(info.Env(), "communityOfNode(u)") \
|
|
956
|
+
.ThrowAsJavaScriptException(); \
|
|
957
|
+
return info.Env().Undefined(); \
|
|
958
|
+
} \
|
|
959
|
+
try { \
|
|
960
|
+
node u = jsToNode(info[0]); \
|
|
961
|
+
return Napi::Number::New(info.Env(), \
|
|
962
|
+
static_cast<double>(algo_->getPartition().subsetOf(u))); \
|
|
963
|
+
} catch (const std::exception &e) { \
|
|
964
|
+
throwError(info.Env(), e); \
|
|
965
|
+
return info.Env().Undefined(); \
|
|
966
|
+
} \
|
|
967
|
+
} \
|
|
968
|
+
/** \
|
|
969
|
+
* getPartition() → { membership: Float64Array, count: number } \
|
|
970
|
+
* membership[i] is the community id of node i (indices are partition-internal). \
|
|
971
|
+
* count is the number of distinct non-empty communities. \
|
|
972
|
+
*/ \
|
|
973
|
+
Napi::Value GetPartition(const Napi::CallbackInfo &info) { \
|
|
974
|
+
try { \
|
|
975
|
+
algo_->assureFinished(); \
|
|
976
|
+
const Partition &P = algo_->getPartition(); \
|
|
977
|
+
const auto &vec = P.getVector(); \
|
|
978
|
+
auto buf = Napi::ArrayBuffer::New(info.Env(), \
|
|
979
|
+
vec.size() * sizeof(double)); \
|
|
980
|
+
double *dst = static_cast<double *>(buf.Data()); \
|
|
981
|
+
for (size_t i = 0; i < vec.size(); ++i) \
|
|
982
|
+
dst[i] = static_cast<double>(vec[i]); \
|
|
983
|
+
Napi::Object result = Napi::Object::New(info.Env()); \
|
|
984
|
+
result.Set("membership", \
|
|
985
|
+
Napi::Float64Array::New(info.Env(), vec.size(), buf, 0)); \
|
|
986
|
+
result.Set("count", Napi::Number::New(info.Env(), \
|
|
987
|
+
static_cast<double>(P.numberOfSubsets()))); \
|
|
988
|
+
return result; \
|
|
989
|
+
} catch (const std::exception &e) { \
|
|
990
|
+
throwError(info.Env(), e); \
|
|
991
|
+
return info.Env().Undefined(); \
|
|
992
|
+
} \
|
|
993
|
+
} \
|
|
994
|
+
/** \
|
|
995
|
+
* getCommunities() → number[][] \
|
|
996
|
+
* Each inner array holds the node ids belonging to one community. \
|
|
997
|
+
* Communities are ordered by ascending internal community id. \
|
|
998
|
+
*/ \
|
|
999
|
+
Napi::Value GetCommunities(const Napi::CallbackInfo &info) { \
|
|
1000
|
+
try { \
|
|
1001
|
+
algo_->assureFinished(); \
|
|
1002
|
+
const Partition &P = algo_->getPartition(); \
|
|
1003
|
+
std::map<NetworKit::index, std::vector<node>> comMap; \
|
|
1004
|
+
P.forEntries([&](NetworKit::index u, NetworKit::index cid) { \
|
|
1005
|
+
comMap[cid].push_back(static_cast<node>(u)); \
|
|
1006
|
+
}); \
|
|
1007
|
+
Napi::Array outer = Napi::Array::New(info.Env(), comMap.size()); \
|
|
1008
|
+
uint32_t ci = 0; \
|
|
1009
|
+
for (auto &kv : comMap) { \
|
|
1010
|
+
Napi::Array inner = Napi::Array::New(info.Env(), kv.second.size()); \
|
|
1011
|
+
for (uint32_t ni = 0; ni < (uint32_t)kv.second.size(); ++ni) \
|
|
1012
|
+
inner[ni] = nodeToJs(info.Env(), kv.second[ni]); \
|
|
1013
|
+
outer[ci++] = inner; \
|
|
1014
|
+
} \
|
|
1015
|
+
return outer; \
|
|
1016
|
+
} catch (const std::exception &e) { \
|
|
1017
|
+
throwError(info.Env(), e); \
|
|
1018
|
+
return info.Env().Undefined(); \
|
|
1019
|
+
} \
|
|
1020
|
+
} \
|
|
1021
|
+
/** \
|
|
1022
|
+
* modularity() → number \
|
|
1023
|
+
* Returns the modularity Q ∈ [−0.5, 1.0] of the resulting partition. \
|
|
1024
|
+
*/ \
|
|
1025
|
+
Napi::Value GetModularity(const Napi::CallbackInfo &info) { \
|
|
1026
|
+
try { \
|
|
1027
|
+
algo_->assureFinished(); \
|
|
1028
|
+
Modularity mod; \
|
|
1029
|
+
return Napi::Number::New(info.Env(), \
|
|
1030
|
+
mod.getQuality(algo_->getPartition(), *graphPtr_)); \
|
|
1031
|
+
} catch (const std::exception &e) { \
|
|
1032
|
+
throwError(info.Env(), e); \
|
|
1033
|
+
return info.Env().Undefined(); \
|
|
1034
|
+
} \
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
// ============================================================================
|
|
1038
|
+
// LouvainWrapper (JS class: Louvain)
|
|
1039
|
+
// Wraps NetworKit::PLM – Parallel Louvain Method, a multi-level modularity
|
|
1040
|
+
// maximiser. Operates on undirected graphs.
|
|
1041
|
+
// ============================================================================
|
|
1042
|
+
class LouvainWrapper : public Napi::ObjectWrap<LouvainWrapper> {
|
|
1043
|
+
public:
|
|
1044
|
+
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
1045
|
+
Napi::Function func = DefineClass(env, "Louvain", {
|
|
1046
|
+
InstanceMethod("run", &LouvainWrapper::Run),
|
|
1047
|
+
InstanceMethod("hasFinished", &LouvainWrapper::HasFinished),
|
|
1048
|
+
InstanceMethod("numberOfCommunities",&LouvainWrapper::NumberOfCommunities),
|
|
1049
|
+
InstanceMethod("communityOfNode", &LouvainWrapper::CommunityOfNode),
|
|
1050
|
+
InstanceMethod("getPartition", &LouvainWrapper::GetPartition),
|
|
1051
|
+
InstanceMethod("getCommunities", &LouvainWrapper::GetCommunities),
|
|
1052
|
+
InstanceMethod("modularity", &LouvainWrapper::GetModularity),
|
|
1053
|
+
});
|
|
1054
|
+
exports.Set("Louvain", func);
|
|
1055
|
+
return exports;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* JS: new Louvain(graph [, refine=false, gamma=1.0, maxIter=32, turbo=true, recurse=true])
|
|
1060
|
+
*
|
|
1061
|
+
* @param graph An undirected Graph or GraphR.
|
|
1062
|
+
* @param refine Add a second refinement pass (default false).
|
|
1063
|
+
* @param gamma Resolution parameter: 1.0 = standard modularity (default 1.0).
|
|
1064
|
+
* @param maxIter Maximum move-phase iterations (default 32).
|
|
1065
|
+
* @param turbo Faster mode with O(n) extra memory per thread (default true).
|
|
1066
|
+
* @param recurse Use recursive coarsening (default true).
|
|
1067
|
+
*/
|
|
1068
|
+
explicit LouvainWrapper(const Napi::CallbackInfo &info)
|
|
1069
|
+
: Napi::ObjectWrap<LouvainWrapper>(info) {
|
|
1070
|
+
if (info.Length() < 1) {
|
|
1071
|
+
Napi::TypeError::New(info.Env(),
|
|
1072
|
+
"Louvain(graph [, refine, gamma, maxIter, turbo, recurse])")
|
|
1073
|
+
.ThrowAsJavaScriptException();
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
try {
|
|
1077
|
+
bool refine = info.Length() >= 2 && info[1].As<Napi::Boolean>();
|
|
1078
|
+
double gamma = info.Length() >= 3
|
|
1079
|
+
? info[2].As<Napi::Number>().DoubleValue() : 1.0;
|
|
1080
|
+
count maxIter = info.Length() >= 4
|
|
1081
|
+
? static_cast<count>(info[3].As<Napi::Number>().DoubleValue())
|
|
1082
|
+
: 32;
|
|
1083
|
+
bool turbo = info.Length() >= 5
|
|
1084
|
+
? (bool)info[4].As<Napi::Boolean>() : true;
|
|
1085
|
+
bool recurse = info.Length() >= 6
|
|
1086
|
+
? (bool)info[5].As<Napi::Boolean>() : true;
|
|
1087
|
+
|
|
1088
|
+
graphRef_ = Napi::Persistent(info[0].As<Napi::Object>());
|
|
1089
|
+
const Graph &G = extractGraph(info[0]);
|
|
1090
|
+
graphPtr_ = &G;
|
|
1091
|
+
algo_ = std::make_unique<PLM>(G, refine, gamma, "balanced",
|
|
1092
|
+
maxIter, turbo, recurse);
|
|
1093
|
+
} catch (const std::exception &e) {
|
|
1094
|
+
throwError(info.Env(), e);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
private:
|
|
1099
|
+
Napi::ObjectReference graphRef_;
|
|
1100
|
+
const Graph *graphPtr_ = nullptr;
|
|
1101
|
+
std::unique_ptr<PLM> algo_;
|
|
1102
|
+
|
|
1103
|
+
CLUSTERING_COMMON_METHODS()
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
// ============================================================================
|
|
1107
|
+
// LeidenWrapper (JS class: Leiden)
|
|
1108
|
+
// Wraps NetworKit::ParallelLeiden – a parallel implementation of the Leiden
|
|
1109
|
+
// community detection algorithm. Operates on undirected graphs.
|
|
1110
|
+
//
|
|
1111
|
+
// Note: The NetworKit implementation may produce a small fraction of
|
|
1112
|
+
// internally disconnected communities. Use with caution on graphs where
|
|
1113
|
+
// strict connectivity guarantees are required.
|
|
1114
|
+
// ============================================================================
|
|
1115
|
+
class LeidenWrapper : public Napi::ObjectWrap<LeidenWrapper> {
|
|
1116
|
+
public:
|
|
1117
|
+
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
1118
|
+
Napi::Function func = DefineClass(env, "Leiden", {
|
|
1119
|
+
InstanceMethod("run", &LeidenWrapper::Run),
|
|
1120
|
+
InstanceMethod("hasFinished", &LeidenWrapper::HasFinished),
|
|
1121
|
+
InstanceMethod("numberOfCommunities",&LeidenWrapper::NumberOfCommunities),
|
|
1122
|
+
InstanceMethod("communityOfNode", &LeidenWrapper::CommunityOfNode),
|
|
1123
|
+
InstanceMethod("getPartition", &LeidenWrapper::GetPartition),
|
|
1124
|
+
InstanceMethod("getCommunities", &LeidenWrapper::GetCommunities),
|
|
1125
|
+
InstanceMethod("modularity", &LeidenWrapper::GetModularity),
|
|
1126
|
+
});
|
|
1127
|
+
exports.Set("Leiden", func);
|
|
1128
|
+
return exports;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* JS: new Leiden(graph [, iterations=3, randomize=true, gamma=1.0])
|
|
1133
|
+
*
|
|
1134
|
+
* @param graph An undirected Graph or GraphR.
|
|
1135
|
+
* @param iterations Number of Leiden iterations to run (default 3).
|
|
1136
|
+
* @param randomize Randomise node order each iteration (default true).
|
|
1137
|
+
* @param gamma Resolution parameter: 1.0 = standard modularity (default 1.0).
|
|
1138
|
+
*/
|
|
1139
|
+
explicit LeidenWrapper(const Napi::CallbackInfo &info)
|
|
1140
|
+
: Napi::ObjectWrap<LeidenWrapper>(info) {
|
|
1141
|
+
if (info.Length() < 1) {
|
|
1142
|
+
Napi::TypeError::New(info.Env(),
|
|
1143
|
+
"Leiden(graph [, iterations, randomize, gamma])")
|
|
1144
|
+
.ThrowAsJavaScriptException();
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
try {
|
|
1148
|
+
int iterations = info.Length() >= 2
|
|
1149
|
+
? static_cast<int>(info[1].As<Napi::Number>().DoubleValue())
|
|
1150
|
+
: 3;
|
|
1151
|
+
bool randomize = info.Length() >= 3
|
|
1152
|
+
? (bool)info[2].As<Napi::Boolean>() : true;
|
|
1153
|
+
double gamma = info.Length() >= 4
|
|
1154
|
+
? info[3].As<Napi::Number>().DoubleValue() : 1.0;
|
|
1155
|
+
|
|
1156
|
+
graphRef_ = Napi::Persistent(info[0].As<Napi::Object>());
|
|
1157
|
+
const Graph &G = extractGraph(info[0]);
|
|
1158
|
+
graphPtr_ = &G;
|
|
1159
|
+
algo_ = std::make_unique<ParallelLeiden>(G, iterations, randomize, gamma);
|
|
1160
|
+
} catch (const std::exception &e) {
|
|
1161
|
+
throwError(info.Env(), e);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
private:
|
|
1166
|
+
Napi::ObjectReference graphRef_;
|
|
1167
|
+
const Graph *graphPtr_ = nullptr;
|
|
1168
|
+
std::unique_ptr<ParallelLeiden> algo_;
|
|
1169
|
+
|
|
1170
|
+
CLUSTERING_COMMON_METHODS()
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
// ============================================================================
|
|
1174
|
+
// Free functions: readMETIS, readEdgeList
|
|
1175
|
+
// ============================================================================
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* JS: readMETIS(path) → Graph
|
|
1179
|
+
*/
|
|
1180
|
+
static Napi::Value ReadMETIS(const Napi::CallbackInfo &info) {
|
|
1181
|
+
if (info.Length() < 1) {
|
|
1182
|
+
Napi::TypeError::New(info.Env(), "readMETIS(path)").ThrowAsJavaScriptException();
|
|
1183
|
+
return info.Env().Undefined();
|
|
1184
|
+
}
|
|
1185
|
+
try {
|
|
1186
|
+
std::string path = info[0].As<Napi::String>().Utf8Value();
|
|
1187
|
+
METISGraphReader reader;
|
|
1188
|
+
// reader returns a GraphW by value; move it onto the heap
|
|
1189
|
+
auto *gw = new GraphW(reader.read(path));
|
|
1190
|
+
auto ext = Napi::External<GraphW>::New(info.Env(), gw);
|
|
1191
|
+
return g_GraphCtor.New({ext});
|
|
1192
|
+
} catch (const std::exception &e) {
|
|
1193
|
+
throwError(info.Env(), e);
|
|
1194
|
+
return info.Env().Undefined();
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* JS: readEdgeList(path, separator=' ', firstNode=0, directed=false, commentPrefix='#') → Graph
|
|
1200
|
+
*/
|
|
1201
|
+
static Napi::Value ReadEdgeList(const Napi::CallbackInfo &info) {
|
|
1202
|
+
if (info.Length() < 1) {
|
|
1203
|
+
Napi::TypeError::New(info.Env(),
|
|
1204
|
+
"readEdgeList(path [, separator, firstNode, directed, commentPrefix])")
|
|
1205
|
+
.ThrowAsJavaScriptException();
|
|
1206
|
+
return info.Env().Undefined();
|
|
1207
|
+
}
|
|
1208
|
+
try {
|
|
1209
|
+
std::string path = info[0].As<Napi::String>().Utf8Value();
|
|
1210
|
+
char sep = info.Length() >= 2
|
|
1211
|
+
? info[1].As<Napi::String>().Utf8Value()[0]
|
|
1212
|
+
: ' ';
|
|
1213
|
+
node firstNode = info.Length() >= 3
|
|
1214
|
+
? static_cast<node>(info[2].As<Napi::Number>().DoubleValue())
|
|
1215
|
+
: 0;
|
|
1216
|
+
bool directed = info.Length() >= 4 && info[3].As<Napi::Boolean>();
|
|
1217
|
+
std::string cmt = info.Length() >= 5
|
|
1218
|
+
? info[4].As<Napi::String>().Utf8Value()
|
|
1219
|
+
: "#";
|
|
1220
|
+
|
|
1221
|
+
EdgeListReader reader(sep, firstNode, cmt, /*continuous=*/true, directed);
|
|
1222
|
+
auto *gw = new GraphW(reader.read(path));
|
|
1223
|
+
auto ext = Napi::External<GraphW>::New(info.Env(), gw);
|
|
1224
|
+
return g_GraphCtor.New({ext});
|
|
1225
|
+
} catch (const std::exception &e) {
|
|
1226
|
+
throwError(info.Env(), e);
|
|
1227
|
+
return info.Env().Undefined();
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
// ============================================================================
|
|
1232
|
+
// Module entry point
|
|
1233
|
+
// ============================================================================
|
|
1234
|
+
static Napi::Object InitModule(Napi::Env env, Napi::Object exports) {
|
|
1235
|
+
// Order matters: Graph and GraphR must be initialised before algorithm
|
|
1236
|
+
// wrappers so that g_GraphCtor / g_GraphRCtor are set when extractGraph()
|
|
1237
|
+
// is called inside algorithm constructors.
|
|
1238
|
+
GraphWrapper::Init(env, exports);
|
|
1239
|
+
GraphRWrapper::Init(env, exports);
|
|
1240
|
+
BetweennessWrapper::Init(env, exports);
|
|
1241
|
+
PageRankWrapper::Init(env, exports);
|
|
1242
|
+
DegreeCentralityWrapper::Init(env, exports);
|
|
1243
|
+
ConnectedComponentsWrapper::Init(env, exports);
|
|
1244
|
+
LouvainWrapper::Init(env, exports);
|
|
1245
|
+
LeidenWrapper::Init(env, exports);
|
|
1246
|
+
|
|
1247
|
+
exports.Set("readMETIS", Napi::Function::New(env, ReadMETIS));
|
|
1248
|
+
exports.Set("readEdgeList", Napi::Function::New(env, ReadEdgeList));
|
|
1249
|
+
|
|
1250
|
+
return exports;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
NODE_API_MODULE(icebug, InitModule)
|