Expand description
Barabási–Albert preferential-attachment random graph — PSUMTREE variants (ALGO-GN-020).
Counterparts of the IGRAPH_BARABASI_PSUMTREE and
IGRAPH_BARABASI_PSUMTREE_MULTIPLE branches of
igraph_barabasi_game() in references/igraph/src/games/barabasi.c
(igraph_i_barabasi_game_psumtree_multiple at lines ~166-294 and
igraph_i_barabasi_game_psumtree at lines ~296-414).
Both variants attach m (or outseq[i]) outgoing edges from every
new vertex i, choosing destinations weighted by
attraction(deg(v)) = pow(deg(v), power) + A (with the C-style
special case pow(0, 0) == 1). Sampling uses a Fenwick BIT
(PsumTree) shared with crate::lastcit_game /
crate::recent_degree_game for O(log n) point-set + binary-lifted
prefix-search.
§Variants
-
barabasi_game_psumtree— simple variant. Each of themdraws temporarily zeros the chosen vertex’s weight in the BIT so that the same target cannot be picked twice within the same step. After themdraws complete, the weights of the chosen vertices are refreshed back to their properattraction(deg(v)). No within-step multi-edges by construction. (Cross-step duplicates are impossible too because the source vertex is fresh each step, and the simple-graph guarantee is the contract.) -
barabasi_game_psumtree_multiple— multi-edge variant. The BIT prefix-sum is snapshotted once at the start of each step, and allmdraws sample against the unchanged tree. The same target may therefore be drawn twice within one step, producing multi-edges. After all draws, the affected vertices’ weights are refreshed in batch.
§Common parameters
nodes— vertex count.nodes = 0returns the empty graph.power— exponent inpow(deg, power). Negative values are permitted only when there are no zero-degree vertices being sampled (the upstream contract is thatA > 0rules that out — we forward the same rule).m— constant per-step out-degree, used whenoutseq = None.outseq— when provided, must have lengthnodes. The first entry is ignored (vertex 0 has no outgoing edges per the seed convention). Fori ≥ 1,outseq[i]overridesm.outpref— whentruethe new vertex’s own out-degree counts toward its attraction (total-degree model). Forced totruewhendirected = false.a— constant attractiveness term added to every weight. Whenoutpref = false, must be strictly positive so that zero-degree vertices have non-zero probability. Whenoutpref = true, may be zero but must be non-negative.directed— emit directed edges (older → newer convention matches BAG variant).seed— initialises an internalSplitMix64; the output is deterministic for fixed parameters and seed.
§Construction guarantees
- No self-loops by construction — the new vertex
iis added to the BIT after itsmoutgoing draws complete. - No cross-step multi-edges: source
iis unique each step, so all duplicates can only land within a single step. The simple variant rules those out; the multiple variant allows them. - Always-cite fallback: when
m ≥ i, allipreviously-added vertices are cited (deterministically), matching upstream’sno_of_neighbors >= ibranch (multiple variant only — the simple variant cannot satisfym ≥ iwithout running out of distinct targets, which the BIT-zeroing scheme also handles implicitly). - Zero-sum fallback: when the BIT total is zero, the sample
falls back to a uniform draw over
[0, i). Withoutpref = trueandA > 0, this branch only fires in the very first step (where the seed vertex’s weight is set to1.0, so the sum is positive).
§Cost
O(n · m · log n) for the BIT searches/updates; O(n + m·(n-1))
memory for the edge list. Compares favourably to the BAG variant’s
O(n · m) for small m, and is asymptotically better than O(n²)
naive cumulative-sum sampling.
Functions§
- barabasi_
game_ psumtree - PSUMTREE (simple) variant — no within-step multi-edges.
- barabasi_
game_ psumtree_ multiple PSUMTREE_MULTIPLEvariant — within-step multi-edges allowed.