@graphty/graphty-element / session / GraphStatistics
Interface: GraphStatistics ​
Defined in: graphty-element/src/session/types.ts:500
The facts about the graph's shape that a consumer would otherwise compute for itself.
Every field is derived from one snapshot and cached against it, so the first read after a change pays for the walk and every later read in the same revision is free.
Properties ​
components ​
readonlycomponents:ComponentStatistics
Defined in: graphty-element/src/session/types.ts:569
The connected-component shape.
degreeHistogram? ​
readonlyoptionaldegreeHistogram?:Histogram
Defined in: graphty-element/src/session/types.ts:553
How the total degree is distributed: the same measure GraphStatistics.degreeRange summarises, binned the way RunResult.histogram bins a count. One bar per degree when there are few distinct degrees, whole-number bands otherwise; the bars' counts add up to GraphStatistics.nodeCount.
session.data.statistics() always fills it in. It is optional only so statistics a caller builds by hand, to pass to recommendLayout or a cost estimate, need not build one.
const histogram = session.data.statistics().degreeHistogram;
// binning "per-value": bins[i].from === bins[i].to, one degree eachdegreeRange ​
readonlydegreeRange: readonly [number,number]
Defined in: graphty-element/src/session/types.ts:528
The smallest and the largest total degree in the graph; [0, 0] when there are no nodes.
density ​
readonlydensity:number
Defined in: graphty-element/src/session/types.ts:509
Edges as a fraction of the pairs that could carry one, self-loops excluded from both halves. Zero for a graph with fewer than two nodes.
directedness ​
readonlydirectedness:"unknown"|"mixed"|"directed"|"undirected"
Defined in: graphty-element/src/session/types.ts:518
Whether the graph is directed, as a fact about the graph rather than a guess per edge.
"unknown" is the honest answer for an empty graph the element was never told about: under data.directed: "auto" nothing has settled the question yet. "mixed" is in the union because a format can report it; the element does not produce it today, because a snapshot carries one flag for the whole graph.
directednessSource ​
readonlydirectednessSource:DirectionProvenance
Defined in: graphty-element/src/session/types.ts:520
Where GraphStatistics.directedness came from, so a reader can qualify the claim.
edgeCount ​
readonlyedgeCount:number
Defined in: graphty-element/src/session/types.ts:504
Edges in the snapshot, self-loops and repeats included.
meanDegree ​
readonlymeanDegree:number
Defined in: graphty-element/src/session/types.ts:538
The mean total degree, over the same measure GraphStatistics.degreeRange summarises: both ends of every edge counted, so a self-loop contributes two. Zero for an empty graph.
It is published because the alternative is every consumer deriving it from the edge count, and 2m / n is the undirected reading: on a directed graph it double-counts, and on any graph it disagrees with the range printed beside it the moment self-loops are involved. One number measured from the same vector as the range cannot drift from it.
nodeCount ​
readonlynodeCount:number
Defined in: graphty-element/src/session/types.ts:502
Nodes in the snapshot.
repeatedEdgeCount ​
readonlyrepeatedEdgeCount:number
Defined in: graphty-element/src/session/types.ts:526
Edges beyond the first between the same pair of endpoints.
selfLoopCount ​
readonlyselfLoopCount:number
Defined in: graphty-element/src/session/types.ts:524
Edges whose two endpoints are the same node.
transitivity? ​
readonlyoptionaltransitivity?:number
Defined in: graphty-element/src/session/types.ts:567
The share of wedges -- two edges meeting at a node -- whose open ends are also joined, so that the three nodes form a triangle: the global clustering coefficient, read with arc direction ignored. 0 on a graph with no triangles (a tree, a grid, a sparse random graph), near 1 on a ring of cliques.
ESTIMATED from a fixed sample of 4,000 wedges drawn with a fixed seed, so it is the same for the same graph and within about 0.01 of the exact value. A pair of opposite arcs between two nodes counts as two edges, which reads such a graph slightly low.
Optional because the element is not the only thing that builds this struct: a statistics object written by hand has none, and a reader of the field takes its absence as "unknown".
weighted ​
readonlyweighted:boolean
Defined in: graphty-element/src/session/types.ts:522
True when any edge carries a weight other than 1.