generate_recent_degree#
- graph_tool.generation.generate_recent_degree(N, m, window, power=1, zero_appeal=1, outpref=False, directed=False)[git][source]#
Generate a multigraph by preferential attachment to the recently gained degree.
- Parameters:
- N
int Number of vertices.
- m
intor iterable ofint Number of edges attached by every new vertex, or a sequence with this number for each vertex (the first value is ignored).
- window
int Number of past steps in which the gained edges are counted.
- power
float(optional, default:1) Exponent \(\alpha\) of the attachment kernel.
- zero_appeal
float(optional, default:1) Attractiveness \(A > 0\) of vertices without recent edges.
- outpref
bool(optional, default:False) If
True, the edges created by a vertex also count as gained.- directed
bool(optional, default:False) If
True, a directed graph is generated, with edges from the new vertices to the older ones.
- N
- Returns:
- g
Graph The generated multigraph.
- g
See also
price_networkPreferential attachment
generate_preferential_agingPreferential attachment with aging
Notes
The graph starts with a single vertex, and every new vertex \(s\) attaches \(m_s\) edges to existing vertices \(v\), chosen independently (so that parallel edges may form) with probability proportional to
\[w_v = r_v^\alpha + A,\]where \(r_v\) is the number of edges that \(v\) gained in the last
windowsteps, i.e. that were attached to it by the vertices \(s - \text{window}, \dots, s - 1\) (and, withoutpref=True, also the edges created by \(v\) itself, if it is one of them), and \(r_v^\alpha\) is taken to be zero for \(r_v = 0\). The algorithm runs in time \(O(Nm\log N)\).Examples
>>> g = gt.generate_recent_degree(10000, 2, 100) >>> print(g.num_edges(), g.degree_property_map("total").a.max()) 19998 115
A smaller instance is drawn as follows:
>>> g = gt.generate_recent_degree(200, 1, 20) >>> gt.graph_draw(g, pos=gt.sfdp_layout(g), ... output="generate_recent_degree-small.pdf") <...>
Recent-degree preferential attachment graph with \(N=200\), \(m=1\), and a window of 20 steps.#