cfpq_data.graphs.generators.labeled_barabasi_albert_graph#
- labeled_barabasi_albert_graph(n: int, m: int, *, labels: ~typing.List[str] = 'abcd', choice: ~typing.Callable[[~typing.List[str]], str] = <bound method Random.choice of <random.Random object>>, seed: int | None = None) MultiDiGraph [source]#
Returns a random graph according to the Barabási–Albert preferential attachment model. With labeled edges.
A graph of
n
nodes is grown by attaching new nodes each withm
edges that are preferentially attached to existing nodes with high degree.- Parameters:
n (int) -- Number of nodes.
m (int) -- Number of edges to attach from a new node to existing nodes.
labels (Iterable[str]) -- Labels that will be used to mark the edges of the graph.
choice (Callable[[Iterable[str]], str]) -- Function for marking edges.
seed (Union[int, RandomState, None]) -- Indicator of random number generation state.
Examples
>>> from cfpq_data import * >>> g = labeled_barabasi_albert_graph(42, 29, seed=42) >>> g.number_of_nodes() 42 >>> g.number_of_edges() 754
- Returns:
g -- A random graph according to the Barabási–Albert preferential attachment model.
- Return type:
MultiDiGraph
- Raises:
NetworkXError -- If
m
does not satisfy1 <= m < n
.
References
[1]A. L. Barabási and R. Albert "Emergence of scaling in random networks", Science 286, pp 509-512, 1999.