API Reference ​
Complete API documentation for @graphty/algorithms. Every algorithm takes a frozen GraphSnapshot from @graphty/graph-format first and an options object last, and returns typed arrays indexed by node (or edge) index. See Graph Data Structure for building a snapshot and mapping node ids to indices.
Every function and type in the generated TypeDoc
Traversal ​
breadthFirstSearch()- BFS;targetstops early,maxDepthbounds the depth,arcOrdersets the neighbour orderdirectionOptimizedBfs()- BFS that switches to bottom-up steps overreverse()on large frontiersdepthFirstSearch()- DFS in pre- or post-order; takestargetandarcOrderhasCycle()- Whether the graph has a cycletopologicalSort()- Topological order as node indices, or null on a cycleisBipartite()- Bipartiteness and the two sides as a node mask
Components ​
connectedComponents()- Components of an undirected graph: a label per node,count,groups()weaklyConnectedComponents()- Components ignoring directionstronglyConnectedComponents()- Tarjan, components labelled in completion ordercondensation()- Strongly connected components and the condensed DAG
Shortest Paths ​
dijkstra()- Single-source shortest paths over non-negative weights;pathTo(target)bellmanFord()- Single-source shortest paths with negative weights, and the negative-cycle flagbidirectionalDijkstra()- One shortest path, naming the edges takenastar()- A* search, the heuristic taking node indicesallPairsShortestPath()- Every pair, as a row-major typed-array matrix (Floyd-Warshall or one search per source)walkPredArcs(),walkPredEdges()- The arcs or edges of a path from a predecessor array
Spanning Trees ​
kruskalMST()- Kruskal's minimum spanning treeprimMST()- Prim's minimum spanning tree from a start node, optionally spanning every component
Centrality ​
degrees()- Each node's in- and out-degree as counted from the edge list, by the orientation each edge was declared with (on an undirected snapshot too, so in plus out is the degree counted once); also a member of theaccelerated()dispatcherdegreeCentrality()- In-, out- or total degree, optionally normalisedbetweennessCentrality(),edgeBetweennessCentrality()- Brandes betweenness, exact or sampledclosenessCentrality(),nodeClosenessCentrality()- Closeness or harmonic closeness, by hops or by weight, exact or sampledeigenvectorCentrality()- Power iteration; throwsConvergenceErrorwhen it does not convergekatzCentrality()- Attenuated walk countshits()- Hub and authority scorespageRank(),personalizedPageRank()- PageRank, and with a restart vectorDeltaPageRank,PriorityDeltaPageRank- Incremental PageRank engines over a snapshot
Community Detection ​
louvain(),leiden()- Modularity optimisation, seededgirvanNewman()- Divisive clustering by edge betweenness, one label vector per levellabelPropagation(),labelPropagationSynchronous(),labelPropagationSemiSupervised()- Label propagationmodularity()- Newman's modularity of a partition
Clustering ​
kCoreDecomposition()- Core number of every nodehierarchicalClustering()- Agglomerative clustering by hop distance;cut(height)gives clustersmarkovClustering()- Markov clustering (MCL)spectralClustering()- Spectral clustering on the graph LaplacianteraHAC(),syncClustering(),grsbm()- Research clustering algorithms
Flow and Cuts ​
maxFlow()- Maximum flow (Edmonds-Karp or Ford-Fulkerson), flow per edge and the minimum cutminSTCut()- Minimum cut between two nodesstoerWagner(),kargerMinCut()- Global minimum cut, exact or seeded randomisedbipartiteFlowNetwork()- The flow network of a bipartite matching problem
Matching and Isomorphism ​
maximumBipartiteMatching(),greedyBipartiteMatching()- Bipartite matchingsisGraphIsomorphic(),findAllIsomorphisms()- Graph isomorphism, with node and edge match callbacks
Link Prediction ​
commonNeighborsScore(),commonNeighborsForPairs(),commonNeighborsPrediction(),getTopCandidatesForNode(),evaluateCommonNeighbors()- Common neighboursadamicAdarScore(),adamicAdarForPairs(),adamicAdarPrediction(),getTopAdamicAdarCandidatesForNode(),evaluateAdamicAdar(),compareAdamicAdarWithCommonNeighbors()- Adamic-Adar
Acceleration ​
accelerated()- Runs the algorithms through an accelerator such as@graphty/webgpu-graph-algorithmswhere it implements them, and on the CPU otherwiseAlgorithmAcceleratorand the*Likeresult types - The seam an accelerator implements
Data Structures and Errors ​
PriorityQueue,UnionFind- General-purpose structuresIndexedMinHeap,IntUnionFind,arcSourceIn()- The index-based structures the algorithms shareConvergenceError,PathWalkError- What an algorithm throws when it cannot finish
Deprecated ​
indexed- The namespace algorithms 2.x offered these functions under;indexed.pageRankispageRank. Removed in 4.0. The migration guide lists the replacement for every other 2.x export.