apache / age

Graph database optimized for fast analysis and real-time data processing. It is provided as an extension to PostgreSQL.
https://age.apache.org
Apache License 2.0
3.07k stars 409 forks source link

Barabási–Albert Graph #278

Open JoshInnis opened 2 years ago

JoshInnis commented 2 years ago

Returns a random graph using Barabási–Albert preferential attachment

A graph of nodes is grown by attaching new nodes each with edges that are preferentially attached to existing nodes with high degree.

Description: The network begins with an initial connected network of m_0 nodes.

New nodes are added to the network one at a time. Each new node is connected to m <= m_0 existing nodes with a probability that is proportional to the number of links that the existing nodes already have. Formally, the probability p_i that the new node is connected to node i is

Image

where k_i is the degree of node i and the sum is made over all pre-existing nodes j (i.e. the denominator results in twice the current number of edges in the network). Heavily linked nodes ("hubs") tend to quickly accumulate even more links, while nodes with only a few links are unlikely to be chosen as the destination for a new link. The new nodes have a "preference" to attach themselves to the already heavily linked nodes.

Syntax:

ag_catalog.age_create_barabasi_albert_graph(graph_name Name, n int, int m, p float
                                    vertex_label_name Name DEFAULT = NULL,
                                    vertex_properties agtype DEFAULT = NULL,
                                    edge_label_name Name DEAULT = NULL,
                                    edge_properties agtype DEFAULT = NULL,
                                    bidirectional bool DEFAULT = true)

Input:

MatheusFarias03 commented 1 year ago

Would be happy to contribute for this one!