Skip to content

Algorithm reference ​

Every graphty algorithm is a method on a Cytoscape collection and on the core, named graphty plus the algorithm name. cy.graphtyPageRank() runs on the whole graph, and cy.$("node.team, edge.team").graphtyLouvain() on the elements the selector matches. Include the edges you want read: a collection of nodes alone has no edges. Each method takes one optional options object and returns its result synchronously, on the CPU. 17 of them also have an ...Async twin, named under each method below, that takes the same options, returns a promise, and runs on the GPU when the runtime has a usable WebGPU device.

js
import cytoscape from "cytoscape";
import graphtyCytoscape from "@graphty/cytoscape-extensions";

cytoscape.use(graphtyCytoscape);

const cy = cytoscape({ headless: true });
await cy.graphtyDataset("karate");

// The synchronous method runs on the CPU; `field` also writes each score into data("rank").
const pr = cy.graphtyPageRank({ dampingFactor: 0.9, field: "rank" });
console.log(pr.score("#0"), cy.$("#0").data("rank"));

// The Async twin waits for the GPU decision, then reports which backend ran.
const prAsync = await cy.graphtyPageRankAsync({ dampingFactor: 0.9 });
console.log(prAsync.backend.ran, prAsync.backend.reason);

On a machine with no WebGPU device the last line prints cpu and the reason, for example no usable WebGPU device: ....

How to read this page ​

The first table lists the options every method takes. Each method then says what it finds, what it returns, whether it reads edge weights, and which options it adds. A method throws on an option that neither its table nor the common table lists. An empty Default cell means there is no fixed value: the Meaning cell says what happens when you leave the option out. The result types are defined at the end of the page.

Algorithms explains which nodes and edges a call reads, the options that name nodes, the result shapes, field and the errors a method throws.

Methods by task ​

The methods below are listed alphabetically. This table groups them by what you want to find, the usual first choice first, and drops the graphty prefix from each name.

TaskMethods
Important nodesPageRank, Degree, Betweenness, Closeness, Eigenvector, Katz, HITS, PersonalizedPageRank, DeltaPageRank, EdgeBetweenness, KCoreDecomposition, TriangleCount
Communities, any numberLouvain, Leiden, LabelPropagation, MarkovClustering, GirvanNewman (slow; keeps every level), Grsbm
Communities, a number you chooseSpectralClustering, HierarchicalClustering with cutAt({ clusters }), SyncClustering, TeraHAC (set numClusters or distanceThreshold; with neither it returns one cluster)
Spread known labelsLabelPropagationSemiSupervised
Connected piecesConnectedComponents, StronglyConnectedComponents, WeaklyConnectedComponents, Condensation
Routes and walksDijkstra, AStar, BidirectionalDijkstra, BellmanFord (negative weights), AllPairsShortestPath, BreadthFirstSearch, DepthFirstSearch
TreesKruskalMST, PrimMST, TopologicalSort
Flow and cutsMaxFlow, MinSTCut, StoerWagner, KargerMinCut
Matching and structureMaximumBipartiteMatching, IsBipartite, HasCycle, IsGraphIsomorphic, Modularity (scores a partition)
Missing linksTopAdamicAdarCandidatesForNode, AdamicAdarPrediction, CommonNeighborsPrediction, EvaluateAdamicAdar

The remaining methods are variants of these: the pair and score forms of the link-prediction methods, graphtyDegrees, graphtyDirectionOptimizedBfs, graphtyGreedyBipartiteMatching, graphtyFindAllIsomorphisms, graphtyLabelPropagationSynchronous and the comparison of the two link scores.

Options every algorithm takes ​

OptionTypeDefaultMeaning
directedbooleanfalseRead the edges as directed (source to target). Default false, except where an algorithm says otherwise.
weightstring | ((edge: EdgeSingular) => number)every edge weighs 1Edge data field holding the weight, or a function of the edge. Each method below says whether it reads weights; one that does not throws when you pass weight.
fieldstringWrite each element's value into data(field), so a stylesheet can map it: the score, the cluster number, the distance from root (Infinity when unreachable) or the search depth (NaN when not visited). A method marked "Takes no field" below throws when you pass it.
gpu"auto" | "off" | "require""auto"The ...Async methods only: "auto" (default) runs on the GPU when the runtime has a usable WebGPU device, "off" runs on the CPU, "require" throws instead of running on the CPU when no device is available. The synchronous methods always run on the CPU and reject "require". Any other value throws a TypeError.

The algorithms defined only for directed graphs (graphtyTopologicalSort, graphtyStronglyConnectedComponents, graphtyCondensation, graphtyDeltaPageRank) default directed to true.

Every algorithm ​

graphtyAStar ​

The shortest path from root to goal, guided by an estimate of the distance left; a negative weight throws.

Returns PointPathResult. Reads edge weights from weight. Takes no field. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
goalNodeSelectionrequiredThe node to reach.
rootNodeSelectionrequiredThe start node: a selector or a collection (its first node).
heuristic(node: NodeSingular) => number0An estimate of the distance left from a node to goal, never more than the real one.

graphtyAdamicAdarForPairs ​

The Adamic-Adar score of each given node pair.

Returns number[]. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

With directed: true, a shared neighbor of (source, target) is a node w with arcs source -> w and w -> target, so the score is not symmetric, and a node with no out-arcs has no candidates.

OptionTypeDefaultMeaning
pairsreadonly NodePair[]requiredThe node pairs to score, each [a, b] of selectors or collections.

graphtyAdamicAdarPrediction ​

The node pairs (u, v) with no edge u -> v, ranked by Adamic-Adar score. With directed: true a pair joined only by v -> u is listed, but each pair is scored in one order only, with the node that comes first in the collection as u: a predicted arc from a later node to an earlier one is missed. For a complete directed list from one node, use graphtyTopCandidatesForNode.

Returns PredictedLink[]. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

With directed: true, a shared neighbor of (source, target) is a node w with arcs source -> w and w -> target, so the score is not symmetric, and a node with no out-arcs has no candidates.

OptionTypeDefaultMeaning
includeExistingbooleanfalseAlso score pairs already joined by an arc u -> v.
topKnumberevery pair above 0Keep only the best topK pairs; 0 or less keeps every pair. A pair that scores 0 is never listed, so the list can be shorter than topK. Each pair is listed once, so topK counts distinct pairs; on an undirected graph source is the node that comes first in the collection (see above).

graphtyAdamicAdarScore ​

The Adamic-Adar score of one node pair: its shared neighbors, each counted as 1 / log(degree), so a rare shared neighbor counts more. With directed: true the degree is the out-degree, and a shared neighbor of out-degree 1 counts 1.

Returns number. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

With directed: true, a shared neighbor of (source, target) is a node w with arcs source -> w and w -> target, so the score is not symmetric, and a node with no out-arcs has no candidates.

OptionTypeDefaultMeaning
sourceNodeSelectionrequiredOne node of the pair.
targetNodeSelectionrequiredThe other node of the pair.

graphtyAllPairsShortestPath ​

The shortest distance, and path, between every pair of nodes.

Returns { distance(from: ElementRef, to: ElementRef): number; path(from: ElementRef, to: ElementRef): CollectionReturnValue; readonly hasNegativeWeightCycle: boolean }. Reads edge weights from weight. Takes no field. Async twin, which can run on the GPU: graphtyAllPairsShortestPathAsync.

OptionTypeDefaultMeaning
method"auto" | "floyd-warshall" | "per-source"Strategy override. "auto" (the default): BFS rows on unit weights, Floyd-Warshall on any negative weight, Dijkstra rows below arcCount n^2 / 3, Floyd-Warshall otherwise. "floyd-warshall" always sweeps; "per-source" runs BFS or Dijkstra rows and throws on a negative weight.
pathsbooleantrueKeep the predecessor table so path(from, to) works; it takes 4 n^2 bytes. With false only distance() works and path() throws, and the Async twin can run on the GPU.
maxNodesnumber5,792Refuse larger graphs before allocating.

graphtyBellmanFord ​

Shortest paths from one node when some edge weights are negative, and whether a negative cycle exists.

Returns PathsResult & { readonly hasNegativeWeightCycle: boolean; }. Reads edge weights from weight. Async twin, which can run on the GPU: graphtyBellmanFordAsync.

OptionTypeDefaultMeaning
rootNodeSelectionrequiredThe start node: a selector or a collection (its first node).
cutoffnumberStop relaxing beyond this distance; a node farther away reads as unreachable. Unbounded when absent.

graphtyBetweennessCentrality ​

How often each node lies on the shortest paths between other nodes: the brokers and bridges.

Returns ScoreResult & { betweenness(node: ElementRef): number | undefined; betweennessNormalized(node: ElementRef): number | undefined; }. Reads no edge weights. Async twin, which can run on the GPU: graphtyBetweennessCentralityAsync.

score is NetworkX's value (divided as normalized says). betweenness is always the raw count over ordered pairs, as Cytoscape's built-in gives it (twice score on an undirected graph), and betweennessNormalized is that divided by its largest value.

OptionTypeDefaultMeaning
normalizedbooleanfalseDivide by the number of ordered pairs a node can sit between: (n - 1)(n - 2) directed, half that undirected; with endpoints, n (n - 1) and half that.
knumberDraw this many source nodes instead of using every node; the same node count and k draw the same nodes every time. With sources it must equal the number of sources. The result is not rescaled.
endpointsbooleanfalseCount a path's two ends as lying on it, as NetworkX's endpoints=True does.
sourcesNodeSelectionevery nodeThe nodes to run from, a selector or a collection; default every node. Sums only the shortest paths that start at these nodes, and is not rescaled by n / k as NetworkX does.

graphtyBidirectionalDijkstra ​

The shortest path between two nodes, searched from both ends at once; a negative weight throws.

Returns PointPathResult. Reads edge weights from weight. Takes no field. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
goalNodeSelectionrequiredThe node to reach.
rootNodeSelectionrequiredThe start node: a selector or a collection (its first node).

graphtyBreadthFirstSearch ​

Walks outward from root one hop at a time, recording each node's depth and parent.

Returns SearchResult. Reads no edge weights. Async twin, which can run on the GPU: graphtyBreadthFirstSearchAsync.

OptionTypeDefaultMeaning
goalNodeSelectionStop when this node comes off the queue; it is then found. Every node queued before it is still expanded, so path can list nodes one hop deeper than the goal, with a depth: on a-b, a-c, b-d, c-e with root a and goal c, path ends with d at depth 2.
maxDepthnumberStop expanding at this many hops from the root; unbounded when absent.
rootNodeSelectionrequiredThe start node: a selector or a collection (its first node).

graphtyClosenessCentrality ​

How near each node is to all others: 1 / the sum of its shortest-path distances.

Returns ScoreResult & { closeness(node: ElementRef): number | undefined; }. Reads edge weights from weight. Async twin, which can run on the GPU: graphtyClosenessCentralityAsync.

OptionTypeDefaultMeaning
normalizedbooleanfalseMultiply by the share of the other nodes that are reached, reached / (n - 1), which changes nothing on a connected graph; with harmonic, divide by n - 1 instead. For NetworkX's closeness_centrality (its default wf_improved=True), multiply the value with normalized: true by the number of other nodes reached; the value without normalized times that number is NetworkX's wf_improved=False.
harmonicbooleanfalseSum 1 / distance instead of taking 1 / sum(distance); better on disconnected graphs.
cutoffnumberevery reachable nodeStop searching from nodes this far away or farther. A node past the cutoff is still counted when an edge reaches it from a node closer than the cutoff.
knumberDraw this many source nodes instead of using every node; the same node count and k draw the same nodes every time. With sources it must equal the number of sources. The result is not rescaled.
sourcesNodeSelectionevery nodeThe nodes to run from, a selector or a collection; default every node. Each node's value is 1 / the sum of its distances from these sources, so with source #a on the path a - b - d, b scores 1 and d 0.5. A node no source reaches scores 0, and so does a source no other source reaches. For one node's own closeness, use graphtyNodeClosenessCentrality.

graphtyCommonNeighborsForPairs ​

The number of neighbors each given node pair shares.

Returns number[]. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

With directed: true, a shared neighbor of (source, target) is a node w with arcs source -> w and w -> target, so the score is not symmetric, and a node with no out-arcs has no candidates.

OptionTypeDefaultMeaning
pairsreadonly NodePair[]requiredThe node pairs to score, each [a, b] of selectors or collections.

graphtyCommonNeighborsPrediction ​

The node pairs (u, v) with no edge u -> v, ranked by how many neighbors they share. With directed: true a pair joined only by v -> u is listed, but each pair is scored in one order only, with the node that comes first in the collection as u: a predicted arc from a later node to an earlier one is missed. For a complete directed list from one node, use graphtyTopCandidatesForNode.

Returns PredictedLink[]. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

With directed: true, a shared neighbor of (source, target) is a node w with arcs source -> w and w -> target, so the score is not symmetric, and a node with no out-arcs has no candidates.

OptionTypeDefaultMeaning
includeExistingbooleanfalseAlso score pairs already joined by an arc u -> v.
topKnumberevery pair above 0Keep only the best topK pairs; 0 or less keeps every pair. A pair that scores 0 is never listed, so the list can be shorter than topK. Each pair is listed once, so topK counts distinct pairs; on an undirected graph source is the node that comes first in the collection (see above).

graphtyCommonNeighborsScore ​

The number of neighbors two nodes share.

Returns number. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

With directed: true, a shared neighbor of (source, target) is a node w with arcs source -> w and w -> target, so the score is not symmetric, and a node with no out-arcs has no candidates.

OptionTypeDefaultMeaning
sourceNodeSelectionrequiredOne node of the pair.
targetNodeSelectionrequiredThe other node of the pair.

graphtyCompareAdamicAdarWithCommonNeighbors ​

Both Evaluate methods on the same held-out edges, to compare the two scores.

Returns { adamicAdar: LinkPredictionMetrics; commonNeighbors: LinkPredictionMetrics; }. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

A held-out edge and a non-edge with the same score count as the edge ranked higher, so a score with many ties reads better than it is: when every pair scores 0, every metric is 1. Common-neighbor counts tie often, which also favors them in the comparison. With directed: true, a shared neighbor of (source, target) is a node w with arcs source -> w and w -> target, so the score is not symmetric, and a node with no out-arcs has no candidates. A held-out arc u -> v scores above 0 only while some path u -> w -> v is left in the graph.

OptionTypeDefaultMeaning
edgesreadonly NodePair[]requiredNode pairs that are edges (held out of the graph), which a good score ranks high.
nonEdgesreadonly NodePair[]requiredNode pairs that are not edges, which a good score ranks low.

graphtyCondensation ​

The strongly connected components, plus the graph of components, which has no cycle.

Returns Partition<{ condensed: DerivedGraph; }>. Reads no edge weights. No Async twin: it runs on the CPU only.

condensed.snapshot is the graph of components as a @graphty/graph-format snapshot. Its node i stands for result[i]. Its edges run from e = 0 to edgeCount - 1, and the snapshot methods edgeSource(e) and edgeTarget(e) give the components at each end: for (let e = 0; e < s.edgeCount; e++) console.log(result[s.edgeSource(e)].map((n) => n.id()), result[s.edgeTarget(e)].map((n) => n.id())), with s = result.condensed.snapshot. The other fields of condensed record how @graphty/graph-format derived the graph; you do not need them. Snapshot explains snapshots.

No options of its own.

graphtyConnectedComponents ​

The connected pieces of an undirected graph.

Returns Partition<object>. Reads no edge weights. Async twin, which can run on the GPU: graphtyConnectedComponentsAsync.

No options of its own.

graphtyDegreeCentrality ​

Each node's number of neighbors.

Returns ScoreResult & { degree(node: ElementRef): number | undefined; }. Reads no edge weights. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
mode"in" | "out" | "total""total"Which neighbors to count: "in", "out" or "total". "in" and "out" need directed: true and throw without it.
normalizedbooleanfalseDivide by n - 1, the most neighbors a node can have.

graphtyDegrees ​

Each node's in-degree and out-degree. Without directed: true an edge counts both ways, so both are the node's degree.

Returns { indegree(node: ElementRef): number | undefined; outdegree(node: ElementRef): number | undefined; }. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

No options of its own.

graphtyDeltaPageRank ​

PageRank computed by passing on only the changes in rank; pass priority: true for ranks that match graphtyPageRank.

Returns ScoreResult & { rank(node: ElementRef): number | undefined; }. Reads edge weights from weight. No Async twin: it runs on the CPU only.

For ranks that match graphtyPageRank({ directed: true }), pass priority: true and leave out maxIterations: the ranks then match a fully converged PageRank to within about 1e-8, so they differ from a default graphtyPageRank by up to its tolerance of 1e-6. With priority, a maxIterations you pass counts processed nodes and can stop the run early without saying so: at 100 on a 200-node graph the ranks are off by a third. Without priority the ranks can differ from PageRank's by up to 0.07 (on the karate club), and a maxIterations in the thousands overflows and throws.

OptionTypeDefaultMeaning
dampingFactornumber0.85Probability of following a link.
maxIterationsnumber100; no limit with priorityRounds, or with priority the number of nodes processed. With priority and no maxIterations, the run goes on until no pending delta is left, so it always converges.
tolerancenumber0.000001Stop when every pending delta is below this.
deltaThresholdnumbertolerance / 10A delta below this is dropped rather than propagated.
prioritybooleanProcess the largest pending delta first; ignores personalization.
personalizationNodeSelection | ((node: NodeSingular) => number)The teleport set: a selection (uniform over it) or a weight per node.

graphtyDepthFirstSearch ​

Walks from root as deep as it can before backtracking, recording each node's depth and parent.

Returns SearchResult. Reads no edge weights. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
goalNodeSelectionStop when this node is reached; it is then found. Nothing after it is visited. Only a pre-order walk can stop early: with order: "post" passing goal throws.
rootNodeSelectionrequiredThe start node: a selector or a collection (its first node).
order"pre" | "post""pre""pre" (default) lists a node when it is first reached, "post" when everything below it is finished.

graphtyDijkstra ​

Shortest paths from one node to every other, for weights of 0 or more; a negative weight throws (use graphtyBellmanFord).

Returns PathsResult. Reads edge weights from weight. Async twin, which can run on the GPU: graphtyDijkstraAsync.

OptionTypeDefaultMeaning
rootNodeSelectionrequiredThe start node: a selector or a collection (its first node).
cutoffnumberStop relaxing beyond this distance; a node farther away reads as unreachable. Unbounded when absent.

graphtyDirectionOptimizedBfs ​

Breadth-first search that switches to a bottom-up search when the frontier is large: the same depths as graphtyBreadthFirstSearch, faster on large graphs with short paths.

Returns SearchResult. Reads no edge weights. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
rootNodeSelectionrequiredThe start node: a selector or a collection (its first node).
alphanumber1Switch from top-down to bottom-up once the frontier's out-arcs exceed the unvisited nodes' in-arcs divided by alpha. A bottom-up step reads at most the unvisited nodes' in-arcs, so with an alpha of 1 the search switches once a top-down step would read more arcs than a bottom-up step can.
betanumber18Switch back to top-down once the frontier shrinks below nodeCount / beta nodes.

graphtyEdgeBetweennessCentrality ​

How often each edge lies on shortest paths: high values mark the bridges between groups.

Returns ScoreResult. Reads no edge weights. Async twin, which can run on the GPU: graphtyEdgeBetweennessCentralityAsync.

OptionTypeDefaultMeaning
sourcesNodeSelectionevery nodeThe nodes to run from, a selector or a collection; default every node. Sums only the shortest paths that start at these nodes, and is not rescaled by n / k as NetworkX does.
normalizedbooleanfalseDivide by (n - 1)(n - 2) on a directed graph, half that on an undirected one.
knumberDraw this many source nodes instead of using every node; the same count draws the same nodes. Not rescaled (see sources).

graphtyEigenvectorCentrality ​

Influence: a node scores high when its neighbors score high.

Returns ScoreResult & { iterations: number; converged: boolean; }. Reads no edge weights. Async twin, which can run on the GPU: graphtyEigenvectorCentralityAsync.

When maxIterations passes do not meet tolerance it throws an error whose code is "E_NOT_CONVERGED", where PageRank, Katz and HITS return converged: false. So converged is always true.

OptionTypeDefaultMeaning
maxIterationsnumber100Iteration cap.
tolerancenumber0.000001Per-node tolerance: the run stops when the L1 change is below n * tolerance.
normalizedbooleantrueRescale the unit-length vector to [0, 1] by min-max.
mode"in" | "out" | "total""in"Which arcs feed a node: "in" (as networkx) the nodes pointing at it, "out" the nodes it points at, "total" both. "in" and "out" need directed: true and throw without it.
startVector(node: NodeSingular) => numberuniformStarting value of each node.

graphtyEvaluateAdamicAdar ​

How well the Adamic-Adar score ranks held-out edges above non-edges.

Returns LinkPredictionMetrics. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

A held-out edge and a non-edge with the same score count as the edge ranked higher, so a score with many ties reads better than it is: when every pair scores 0, every metric is 1. Common-neighbor counts tie often, which also favors them in the comparison. With directed: true, a shared neighbor of (source, target) is a node w with arcs source -> w and w -> target, so the score is not symmetric, and a node with no out-arcs has no candidates. A held-out arc u -> v scores above 0 only while some path u -> w -> v is left in the graph.

OptionTypeDefaultMeaning
edgesreadonly NodePair[]requiredNode pairs that are edges (held out of the graph), which a good score ranks high.
nonEdgesreadonly NodePair[]requiredNode pairs that are not edges, which a good score ranks low.

graphtyEvaluateCommonNeighbors ​

How well the common-neighbor count ranks held-out edges above non-edges.

Returns LinkPredictionMetrics. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

A held-out edge and a non-edge with the same score count as the edge ranked higher, so a score with many ties reads better than it is: when every pair scores 0, every metric is 1. Common-neighbor counts tie often, which also favors them in the comparison. With directed: true, a shared neighbor of (source, target) is a node w with arcs source -> w and w -> target, so the score is not symmetric, and a node with no out-arcs has no candidates. A held-out arc u -> v scores above 0 only while some path u -> w -> v is left in the graph.

OptionTypeDefaultMeaning
edgesreadonly NodePair[]requiredNode pairs that are edges (held out of the graph), which a good score ranks high.
nonEdgesreadonly NodePair[]requiredNode pairs that are not edges, which a good score ranks low.

graphtyFindAllIsomorphisms ​

Every way to map this graph's nodes onto other so that the edges match.

Returns ((node: ElementRef) => NodeSingular | undefined)[]. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
otherstring | Collection | readonly (EdgeSingular | NodeSingular)[]requiredThe graph to compare with, read with the same directed and like the calling collection: its nodes, and the edges in it whose ends are both in it. A collection of nodes alone has no edges, so include them: other: part.union(part.edgesWith(part)). Also takes an array of elements, or a selector over the whole core (for example ".second", matching that graph's nodes and edges).
nodeMatch(a: NodeSingular, b: NodeSingular) => booleanany two mayTwo nodes may be paired only when this returns true; by default any two may.
edgeMatch(a: EdgeSingular, b: EdgeSingular) => booleanany two mayTwo edges may be paired only when this returns true; by default any two may.

graphtyGirvanNewman ​

Communities found by removing the edge with the highest betweenness, round after round.

Returns Partition<{ modularity: number; levels: number; level(k: number): Partition<object>; modularities: number[]; }>. Reads edge weights from weight. No Async twin: it runs on the CPU only.

level(k) is the partition after k rounds of edge removal, for k from 0 (no edge removed) to levels - 1; past the end it returns an empty array. modularities[k] is the modularity of level(k). The result itself, with its modularity, is the level with the highest modularity.

OptionTypeDefaultMeaning
maxCommunitiesnumberStop once a level has at least this many communities of minCommunitySize or more nodes.
minCommunitySizenumber1Communities smaller than this do not count towards maxCommunities.
maxIterationsnumber100Cap on rounds of edge removal.

graphtyGreedyBipartiteMatching ​

A set of edges with no node in common in a bipartite graph, found quickly; not always the largest.

Returns { readonly size: number; mate(node: ElementRef): NodeSingular | undefined }. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
leftNodeSelectionOne side of the bipartite graph; inferred when absent.
rightNodeSelectionThe other side; inferred when absent.
arcs"out" | "both""both"With directed: "both" (default) ignores direction; "out" joins a left node only to its out-neighbors.

graphtyGrsbm ​

Communities found by splitting groups in two along their Fiedler vector. A split is kept only when it raises the modularity of the whole partition.

Returns Partition<object>. Reads edge weights from weight. No Async twin: it runs on the CPU only.

A split is never undone and a group is cut only between 20% and 80% of its members, so the modularity can fall short of graphtyLouvain's or graphtyLeiden's on graphs whose communities are uneven in size.

OptionTypeDefaultMeaning
maxDepthnumber10Clusters at this depth are not split.
maxIterationsnumber100Iteration cap of the eigenvector iteration.
tolerancenumber1e-6Convergence tolerance of the eigenvector iteration.
seednumber42Seed of the iteration's start vectors.
minClusterSizenumber2A cluster is split only when it has at least twice this many members.

graphtyHasCycle ​

Whether the graph has a cycle.

Returns boolean. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

By default the edges are read as undirected, so any two routes between the same nodes form a cycle: a diamond-shaped DAG has one. With directed: true only a directed cycle counts, and the diamond has none.

No options of its own.

graphtyHierarchicalClustering ​

A merge tree of clusters: every node starts alone, and the two closest clusters by hop distance merge until no pair can.

Returns { cut(height: number): Partition<object>; cutAt(by: { readonly clusters: number; } | { readonly distance: number; }): Partition<object>; readonly merges: number; }. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

Distances are hop counts: weights are not read, and nodes with no path between them never merge. cutAt({ clusters: k }) returns the k clusters left after the first merges, and cutAt({ distance: d }) the clusters left by applying every merge up to the first one farther apart than d; a cluster count below the number of connected components or above the node count throws E_BAD_OPTION. cut(height) returns the clusters of the merge tree whose height is height or less, where a node has height 0 and a merge is one more than its taller part. So cut(0) gives every node alone, and a large height gives one cluster per connected component. merges is the number of merges made.

OptionTypeDefaultMeaning
linkage"single" | "complete" | "average" | "ward""single"How the distance between two clusters is read from their members' hop distances: the minimum ("single"), the maximum ("complete"), the mean ("average") or Ward's scaled mean ("ward").
maxNodesnumberno boundRefuse a graph of more nodes than this before allocating its n x n matrices (28 n^2 bytes), with a RangeError of code E_TOO_LARGE and params { nodeCount, maxNodes, bytes }.

graphtyHits ​

Hubs and authorities: a good hub points to good authorities, and a good authority is pointed to by good hubs.

Returns ScoreResult & { hub(node: ElementRef): number | undefined; authority(node: ElementRef): number | undefined; iterations: number; converged: boolean; }. Reads edge weights from weight. Async twin, which can run on the GPU: graphtyHitsAsync.

score is the authority value.

OptionTypeDefaultMeaning
maxIterationsnumber100Iteration cap.
tolerancenumber0.000001Convergence tolerance on the largest single-node change.
normalizedbooleantruetrue: each vector has length 1 (L2 norm). false: each vector is divided by its largest entry, so its top node scores 1.

graphtyIsBipartite ​

Whether the nodes split into two sides with every edge between the sides, and the two sides.

Returns { bipartite: boolean; partitionFirst: NodeCollection; partitionSecond: NodeCollection; }. Reads no edge weights. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
arcs"out" | "both""both"Which arcs of a directed graph to color along. "both" (default) follows out- and in-arcs, which answers for the graph with direction ignored. "out" follows out-arcs only: roots are taken in index order and a node first reached through an in-arc is colored as a new root, so the answer depends on node order. Ignored on an undirected graph.

graphtyIsGraphIsomorphic ​

Whether this graph and other have the same shape, and how their nodes pair up.

Returns { isomorphic: boolean; mapping(node: ElementRef): NodeSingular | undefined; }. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

mapping(node) takes a node of this collection and returns the node of other it is paired with. A node of other, or any node when isomorphic is false, returns undefined.

OptionTypeDefaultMeaning
otherstring | Collection | readonly (EdgeSingular | NodeSingular)[]requiredThe graph to compare with, read with the same directed and like the calling collection: its nodes, and the edges in it whose ends are both in it. A collection of nodes alone has no edges, so include them: other: part.union(part.edgesWith(part)). Also takes an array of elements, or a selector over the whole core (for example ".second", matching that graph's nodes and edges).
nodeMatch(a: NodeSingular, b: NodeSingular) => booleanany two mayTwo nodes may be paired only when this returns true; by default any two may.
edgeMatch(a: EdgeSingular, b: EdgeSingular) => booleanany two mayTwo edges may be paired only when this returns true; by default any two may.

graphtyKCoreDecomposition ​

Each node's core number: the largest k for which the node belongs to a group whose members all have k or more neighbors in the group.

Returns ScoreResult & { maxCore: number; core(k: number): NodeCollection; }. Reads no edge weights. No Async twin: it runs on the CPU only.

score is the core number; core(k) returns the nodes whose core number is k or more.

No options of its own.

graphtyKargerMinCut ​

A minimum cut found by random contraction over many trials: the lightest set of edges whose removal splits the graph.

Returns CutResult. Reads edge weights from weight. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
randomSeednumber42Seed of the edge orders; one seed gives one result, bit for bit.
iterationsnumber100Independent contraction trials; the lightest cut found wins.

graphtyKatzCentrality ​

Influence counted over walks of every length, the shorter walks counting more.

Returns ScoreResult & { iterations: number; converged: boolean; }. Reads edge weights from weight. Async twin, which can run on the GPU: graphtyKatzCentralityAsync.

OptionTypeDefaultMeaning
maxIterationsnumber100Iteration cap.
tolerancenumber0.000001Convergence tolerance on the largest single-node change.
normalizedbooleantrueRescale the scores to [0, 1] by min-max.
alphanumber0.1Attenuation factor applied to a neighbor's score.
betanumber1Base score every node starts with and keeps.

graphtyKruskalMST ​

The minimum spanning forest: the lightest edges that connect every node of each component.

Returns CollectionReturnValue & { totalWeight: number; }. Reads edge weights from weight. Takes no field. No Async twin: it runs on the CPU only.

No options of its own.

graphtyLabelPropagation ​

Communities found by letting each node take the most common label among its neighbors.

Returns Partition<{ iterations: number | undefined; converged: boolean | undefined }>. Reads edge weights from weight. Async twin, which can run on the GPU: graphtyLabelPropagationAsync.

iterations and converged are undefined only when the ...Async twin ran on the GPU, which does not report them; this method always fills them in.

OptionTypeDefaultMeaning
maxIterationsnumber100Work cap, in node visits per node (full-sweep equivalents).
randomSeednumber42Seed of the visit order and of the tie draws.

graphtyLabelPropagationSemiSupervised ​

Spreads the labels of a few seed nodes to the rest of the graph.

Returns Partition<{ iterations: number; converged: boolean; }>. Reads edge weights from weight. No Async twin: it runs on the CPU only.

Cluster numbers are not seed labels: they follow node order, not the order of seeds or the values in the seed field, and field writes those numbers. To find the cluster a label spread to, ask one of its seed nodes: with seeds: ["#33", "#0"], result.cluster("#33") is the cluster of the first label.

OptionTypeDefaultMeaning
maxIterationsnumber100Work cap, in node visits per node (full-sweep equivalents).
randomSeednumber42Seed of the visit order and of the tie draws.
seedsstring | readonly NodeSelection[]requiredSeed labels: the node data field holding them (nodes without it are free), or one selection per label. Free nodes start unlabeled and take a seed label when one reaches them, so every node connected to a seed ends in a seed's cluster. Each connected group of nodes no seed reaches becomes a cluster of its own.

graphtyLabelPropagationSynchronous ​

Label propagation in which every node updates at once, each round.

Returns Partition<{ iterations: number | undefined; converged: boolean | undefined }>. Reads edge weights from weight. Async twin, which can run on the GPU: graphtyLabelPropagationSynchronousAsync.

iterations and converged are undefined only when the ...Async twin ran on the GPU, which does not report them; this method always fills them in.

OptionTypeDefaultMeaning
maxIterationsnumber100Iteration cap.

graphtyLeiden ​

Communities by modularity, as Louvain finds them, with every community connected.

Returns Partition<{ modularity: number; iterations: number; }>. Reads edge weights from weight. No Async twin: it runs on the CPU only.

modularity is measured at the resolution you passed: graphtyModularity({ clusters: result, resolution }) with the same value gives the same number.

OptionTypeDefaultMeaning
resolutionnumber1Resolution gamma: above 1 favors smaller communities.
randomSeednumber42Seed of the visit orders.
maxIterationsnumber100Cap on whole passes over the original graph, each running as many levels as it needs. The result's iterations counts levels.
thresholdnumber1e-7Stop once a pass improves modularity by no more than this.

graphtyLouvain ​

Communities by modularity: groups with more edges inside them than chance would give.

Returns Partition<{ modularity: number; iterations: number; }>. Reads edge weights from weight. No Async twin: it runs on the CPU only.

modularity is measured at the resolution you passed: graphtyModularity({ clusters: result, resolution }) with the same value gives the same number.

OptionTypeDefaultMeaning
resolutionnumber1Resolution gamma: above 1 favors smaller communities.
maxIterationsnumber100Cap on aggregation levels, and on node visits per node within a level.
tolerancenumber1e-6Stop when a level improves modularity by less than this.

graphtyMarkovClustering ​

Communities found by simulating random walks, which stay inside dense regions.

Returns Partition<{ iterations: number; converged: boolean; }>. Reads edge weights from weight. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
maxIterationsnumber100Cap on expansion-inflation rounds.
tolerancenumber1e-6Stop when no matrix entry moved by more than this in a round.
expansionnumber2Matrix power of each expansion step, an integer of at least 1.
inflationnumber2Element-wise power of each inflation step, above 0.
pruningThresholdnumber1e-5Entries below this are dropped after each inflation.
selfLoopsbooleantrueGive every node a self-loop of weight 1 before the first round.

graphtyMaxFlow ​

The most flow that can move from source to sink, the flow on each edge, and a minimum cut.

Returns CutResult & { flow(edge: ElementRef): number | undefined; }. Reads edge weights from weight. No Async twin: it runs on the CPU only.

Edge capacities come from weight; without it every edge has capacity 1. The edges are read as undirected unless you pass directed: true, which a flow network needs: cy.graphtyMaxFlow({ source: "#s", sink: "#t", weight: "capacity", directed: true }). partitionFirst is the source side of the cut. flow(edge) is measured from the edge's source to its target: read undirected, flow that runs the other way is negative; with directed: true it is between 0 and the capacity.

OptionTypeDefaultMeaning
sourceNodeSelectionrequiredThe node the flow leaves.
sinkNodeSelectionrequiredThe node the flow arrives at.
algorithm"edmonds-karp" | "ford-fulkerson""edmonds-karp"How augmenting paths are found: "edmonds-karp" (breadth-first, O(V E^2)) or "ford-fulkerson" (depth-first, O(E f)). Both give the same source side and flow value; the per-edge flows can differ where the maximum flow is not unique.

graphtyMaximumBipartiteMatching ​

The largest set of edges with no node in common in a bipartite graph.

Returns { readonly size: number; mate(node: ElementRef): NodeSingular | undefined }. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
leftNodeSelectionOne side of the bipartite graph; inferred when absent.
rightNodeSelectionThe other side; inferred when absent.
arcs"out" | "both""both"With directed: "both" (default) ignores direction; "out" joins a left node only to its out-neighbors.

graphtyMinSTCut ​

The lightest set of edges whose removal separates source from sink.

Returns CutResult. Reads edge weights from weight. No Async twin: it runs on the CPU only.

Edge capacities come from weight; without it every edge has capacity 1. The edges are read as undirected unless you pass directed: true. partitionFirst is the source side.

OptionTypeDefaultMeaning
sourceNodeSelectionrequiredThe node the flow leaves.
sinkNodeSelectionrequiredThe node the flow arrives at.
algorithm"edmonds-karp" | "ford-fulkerson""ford-fulkerson"How augmenting paths are found: "edmonds-karp" (breadth-first, O(V E^2)) or "ford-fulkerson" (depth-first, O(E f)). Both give the same source side and flow value; the per-edge flows can differ where the maximum flow is not unique.

graphtyModularity ​

Scores a given partition: how many more edges fall inside its clusters than chance would give.

Returns number. Reads edge weights from weight. Takes no field. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
resolutionnumber1Resolution gamma: above 1 favors smaller communities.
clustersstring | readonly NodeSelection[]requiredThe clusters (a partition result, or selections), or the node data field holding each node's cluster.

graphtyNodeClosenessCentrality ​

The closeness of one node, without computing every node's.

Returns number. Reads edge weights from weight. Takes no field. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
rootNodeSelectionrequiredThe start node: a selector or a collection (its first node).
normalizedbooleanfalseMultiply by the share of the other nodes that are reached, reached / (n - 1), which changes nothing on a connected graph; with harmonic, divide by n - 1 instead. For NetworkX's closeness_centrality (its default wf_improved=True), multiply the value with normalized: true by the number of other nodes reached; the value without normalized times that number is NetworkX's wf_improved=False.
harmonicbooleanfalseSum 1 / distance instead of taking 1 / sum(distance); better on disconnected graphs.
cutoffnumberevery reachable nodeStop searching from nodes this far away or farther. A node past the cutoff is still counted when an edge reaches it from a node closer than the cutoff.

graphtyPageRank ​

Importance from links: a node ranks high when high-ranking nodes link to it.

Returns ScoreResult & { rank(node: ElementRef): number | undefined; iterations: number; converged: boolean; }. Reads edge weights from weight. Async twin, which can run on the GPU: graphtyPageRankAsync.

OptionTypeDefaultMeaning
dampingFactornumber0.85Probability of following a link.
maxIterationsnumber100Iteration cap.
tolerancenumber0.000001Convergence tolerance on the per-iteration change.
convergenceNorm"l1" | "max""l1"How the per-iteration change is measured against tolerance: "l1" (default) sums it over all nodes, "max" takes the largest single-node change.
initialRanks(node: NodeSingular) => numberStarting rank of each node.

graphtyPersonalizedPageRank ​

PageRank seen from a set of nodes: importance relative to personalization.

Returns ScoreResult & { rank(node: ElementRef): number | undefined; iterations: number; converged: boolean; }. Reads edge weights from weight. Async twin, which can run on the GPU: graphtyPersonalizedPageRankAsync.

OptionTypeDefaultMeaning
dampingFactornumber0.85Probability of following a link.
maxIterationsnumber100Iteration cap.
tolerancenumber0.000001Convergence tolerance on the per-iteration change.
convergenceNorm"l1" | "max""l1"How the per-iteration change is measured against tolerance: "l1" (default) sums it over all nodes, "max" takes the largest single-node change.
personalizationNodeSelection | ((node: NodeSingular) => number)requiredThe teleport set: a selection (uniform over it) or a weight per node.
initialRanks(node: NodeSingular) => numberStarting rank of each node.

graphtyPrimMST ​

The minimum spanning tree, grown from root.

Returns CollectionReturnValue & { totalWeight: number; }. Reads edge weights from weight. Takes no field. No Async twin: it runs on the CPU only.

OptionTypeDefaultMeaning
rootNodeSelectionthe first nodeThe node the tree grows from.
forestbooleanfalseGrow a tree in every component instead of throwing on a disconnected graph.

graphtySpectralClustering ​

k clusters found by k-means on the eigenvectors of the graph's Laplacian.

Returns Partition<{ converged: boolean; eigenvalues: Float64Array; }>. Reads edge weights from weight. No Async twin: it runs on the CPU only.

Every connected component, an isolated node included, takes a cluster of its own before any component is split. On an 80-node graph of 4 communities, k: 4 finds the communities; add 3 isolated nodes and it returns the 80 nodes as one cluster plus 3 single nodes. Run it on the component you want to cluster, or raise k by the number of extra components.

OptionTypeDefaultMeaning
maxIterationsnumber100Cap on k-means rounds.
tolerancenumber1e-4k-means stops when no centroid moves further than this.
knumberrequiredNumber of clusters, a positive integer.
laplacianType"normalized" | "unnormalized" | "randomWalk""normalized""unnormalized" is D - A, "normalized" is I - D^-1/2 A D^-1/2 with each row of the embedding scaled to unit length, and "randomWalk" is I - D^-1 A.
seednumber42Seed of the starting block and of the k-means seeding.

graphtyStoerWagner ​

The global minimum cut: the lightest set of edges whose removal splits the graph in two.

Returns CutResult. Reads edge weights from weight. No Async twin: it runs on the CPU only.

No options of its own.

graphtyStronglyConnectedComponents ​

Groups of nodes in a directed graph in which every node can reach every other.

Returns Partition<object>. Reads no edge weights. No Async twin: it runs on the CPU only.

No options of its own.

graphtySyncClustering ​

numClusters clusters found by k-means on node embeddings learned from the edges.

Returns Partition<{ loss: number; iterations: number; converged: boolean; }>. Reads no edge weights. No Async twin: it runs on the CPU only.

Unconnected parts of the graph come apart, and so do connected communities: the run stops once the cluster assignment has held for 10 iterations, before further smoothing would blur communities joined by edges into one another. On an 80-node graph of 4 communities the defaults return the 4 communities exactly on most such graphs, in under 20 iterations. converged: true does not mean the clusters are right: each isolated node or extra component takes one of the numClusters centers, so add 3 isolated nodes to that graph and the defaults give two communities the same cluster on most such graphs. Run it on the component you want to cluster, or raise numClusters by the number of extra components (communities then keep clusters of their own, though some split in two).

OptionTypeDefaultMeaning
numClustersnumberrequiredNumber of cluster centers: an integer in [1, nodeCount].
maxIterationsnumber1000Iteration cap.
tolerancenumber1e-6Stop when the loss changes by less than this between iterations. A run also stops once the cluster assignment has stayed the same for 10 iterations in a row.
seednumber42Seed of the embedding initialization and the center draws.
learningRatenumber0.5Fraction of the full step each node takes. The full step (1) moves a node to the mean of its out-neighbors' embeddings. Below 1 every part settles; at 1 a bipartite part swaps sides at every step.
lambdanumber0.1Weight of the neighbor and regularization terms in the reported loss (and its convergence test). The step divides it out, so it does not change the embeddings, except that 0 stops every node where it starts.

graphtyTeraHAC ​

Hierarchical clustering by hop distance, stopped at numClusters clusters or at distanceThreshold, returned as a partition.

Returns Partition<{ merges: number; }>. Reads no edge weights. No Async twin: it runs on the CPU only.

With numClusters, the clusters returned are not the ones left when merging stopped: the run joins those into one tree and splits it again from the top. So a smaller numClusters is not always a coarsening of a larger one, and separate components can share a cluster while connected nodes are split. For clusters that keep separate components apart, use graphtyHierarchicalClustering and its cutAt({ clusters }).

OptionTypeDefaultMeaning
linkage"single" | "complete" | "average" | "ward""average"How the distance between two clusters is read from their members' pairwise distances: the minimum, the maximum, the mean, or ("ward") the mean of the squares.
numClustersnumbermerge until one is leftStop merging at this many clusters; a positive integer.
distanceThresholdnumberno thresholdStop at the first merge whose linkage distance is above this.
useGraphDistancebooleanPairwise distance: hop count along out-arcs (true, the default), or 1 for an arc from the lower to the higher node index and 2 for none (false).
maxNodesnumberno boundRefuse a graph of more nodes than this before allocating the n x n distance matrix (8 n^2 bytes), with a RangeError of code E_TOO_LARGE and params { nodeCount, maxNodes, bytes }.

graphtyTopAdamicAdarCandidatesForNode ​

The nodes root is most likely to link to next, ranked by Adamic-Adar score.

Returns PredictedLink[]. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

With directed: true, a shared neighbor of (source, target) is a node w with arcs source -> w and w -> target, so the score is not symmetric, and a node with no out-arcs has no candidates.

OptionTypeDefaultMeaning
rootNodeSelectionrequiredThe start node: a selector or a collection (its first node).
includeExistingbooleanfalseAlso score pairs already joined by an arc u -> v.
topKnumber10Keep only the best topK candidates; 0 or less keeps every candidate. A candidate that scores 0 is never listed, so the list can be shorter than topK.
candidatesNodeSelectionevery nodeThe nodes to consider linking to root. Those that score 0 are left out of the result.

graphtyTopCandidatesForNode ​

The nodes root is most likely to link to next, ranked by shared neighbors.

Returns PredictedLink[]. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

With directed: true, a shared neighbor of (source, target) is a node w with arcs source -> w and w -> target, so the score is not symmetric, and a node with no out-arcs has no candidates.

OptionTypeDefaultMeaning
rootNodeSelectionrequiredThe start node: a selector or a collection (its first node).
includeExistingbooleanfalseAlso score pairs already joined by an arc u -> v.
topKnumber10Keep only the best topK candidates; 0 or less keeps every candidate. A candidate that scores 0 is never listed, so the list can be shorter than topK.
candidatesNodeSelectionevery nodeThe nodes to consider linking to root. Those that score 0 are left out of the result.

graphtyTopologicalSort ​

The nodes in an order in which every edge points forward; null when the graph has a cycle.

Returns NodeCollection | null. Reads no edge weights. Takes no field. No Async twin: it runs on the CPU only.

No options of its own.

graphtyTriangleCount ​

Each node's number of triangles and clustering coefficient, and the graph's total and transitivity.

Returns ScoreResult & { coefficient(node: ElementRef): number | undefined; total: number; transitivity: number; }. Reads no edge weights. Async twin, which can run on the GPU: graphtyTriangleCountAsync.

score is the node's number of triangles.

No options of its own.

graphtyWeaklyConnectedComponents ​

The pieces of a directed graph that are connected when direction is ignored.

Returns Partition<object>. Reads no edge weights. Async twin, which can run on the GPU: graphtyWeaklyConnectedComponentsAsync.

No options of its own.

Result types ​

A method that takes a node or edge, such as score(ele), accepts an ElementRef: the element, a collection (its first element is used) or a selector. A Partition is an array of node collections, one per cluster, with cluster(node) giving a node's index in that array; some methods add fields to it, shown in their Returns line. A NodePair is [a, b], each a selector or a collection.

ScoreResult ​

Per-element values, keyed by element.

MemberTypeMeaning
score(ele: ElementRef) => number | undefinedThe value of an element of the collection; undefined for one outside it.

PathsResult ​

Paths from one root, in the shape of Cytoscape's dijkstra.

MemberTypeMeaning
distanceTo(node: ElementRef) => numberDistance from the root; Infinity when unreachable.
pathTo(node: ElementRef) => CollectionReturnValueThe path from the root, alternating node, edge, node; empty when unreachable.

SearchResult ​

A walk from one root, in the shape of Cytoscape's bfs / dfs.

MemberTypeMeaning
pathCollectionReturnValueThe visited nodes in visit order, each after the tree edge that reached it.
foundCollectionReturnValueThe goal node when it was reached, else empty.
depth(node: ElementRef) => number | undefinedEdges from the root along the walk's tree (the parent links): the shortest hop count for a breadth-first search, the tree depth for a depth-first search, which can be larger. Undefined when not visited.
parent(node: ElementRef) => NodeSingular | undefinedThe node this one was reached from; undefined for the root and unvisited nodes.

PointPathResult ​

One path between two nodes, in the shape of Cytoscape's aStar.

MemberTypeMeaning
foundbooleanWhether goal can be reached from root.
distancenumberThe length of the path; Infinity when not found.
pathCollectionReturnValueAlternating node, edge, node; empty when not found.

CutResult ​

A cut, like the result of Cytoscape's kargerStein with partition1 and partition2 named partitionFirst and partitionSecond, plus value and without components.

MemberTypeMeaning
valuenumberThe total weight (capacity) of the cut edges.
cutEdgeCollectionThe edges that cross the cut. In graphtyMaxFlow and graphtyMinSTCut with directed: true, only the arcs from partitionFirst to partitionSecond, whose capacities sum to value.
partitionFirstNodeCollectionThe nodes on one side: the source side for a flow or s-t cut.
partitionSecondNodeCollectionThe nodes on the other side.

A predicted link.

MemberTypeMeaning
sourceNodeSingularOne end of the proposed edge.
targetNodeSingularThe other end.
scorenumberThe pair's score; higher is a more likely link.

LinkPredictionMetrics ​

The best-F1 threshold's precision and recall, that F1, and the ranking AUC.

MemberTypeMeaning
precisionnumberThe precision at the score threshold with the best F1. Every metric ranks a held-out edge ahead of a non-edge with the same score, so a score that ties every pair reports 1 for all four.
recallnumberThe recall at that threshold.
f1ScorenumberThe best F1 over every threshold.
aucnumberThe chance that a held-out edge scores above a non-edge, a tie counting as the edge scoring higher; 0.5 when either list is empty.

Try it ​