generate_typed_citation#
- graph_tool.generation.generate_typed_citation(types, pref, m=1, directed=True)[git][source]#
Generate a citation multigraph in which the citation probabilities depend on vertex types.
- Parameters:
- typesiterable of
int Type \(b_v \ge 0\) of every vertex, in the order in which the vertices are added.
- prefiterable of
floator two-dimensional array Attractiveness \(p_r\) of every type \(r\), or a matrix \(p_{sr}\) with the attractiveness of the type \(r\) for a citing vertex of type \(s\).
- m
int(optional, default:1) Number of citations of every new vertex.
- directed
bool(optional, default:True) If
True, a directed graph is generated, with edges from the citing vertices.
- typesiterable of
- Returns:
- g
Graph The generated multigraph.
- g
See also
price_networkPrice’s model
generate_establishmentGrowing model with vertex types
Notes
The vertices are added one at a time, and every new vertex \(t\) cites \(m\) existing vertices \(v\), chosen independently (so that parallel edges may form) with probability proportional to \(p_{b_v}\), or to \(p_{b_tb_v}\) if a matrix is given; if all of them vanish, the vertex is chosen uniformly. The algorithm runs in time \(O(N + EB)\) for \(B\) types.
Examples
>>> types = np.random.randint(0, 2, 1000) >>> g = gt.generate_typed_citation(types, [[1, 0.1], [0.1, 1]], m=3) >>> u, v = g.get_edges().T >>> print((types[u] == types[v]).mean()) 0.90990...
A smaller instance is drawn as follows:
>>> types = np.random.randint(0, 2, 100) >>> g = gt.generate_typed_citation(types, [[1, 0.1], [0.1, 1]], m=2) >>> cmap = matplotlib.colors.ListedColormap( ... ["#9bbedc", "#f28c8e"]) >>> gt.graph_draw(g, pos=gt.sfdp_layout(g), ... vertex_fill_color=g.new_vp("int", vals=types), vcmap=cmap, ... output="generate_typed_citation-small.pdf") <...>
Typed citation graph with \(N=100\), \(m=2\), and two types, with \(p_{rr}=1\) and \(p_{rs}=0.1\) for \(r\neq s\). The vertex colors indicate the types.#