snap_aggregation

snap_aggregation#

graph_tool.generation.snap_aggregation(g, vprops, eprops=[])[git][source]#

Summarize a graph by aggregating its vertices with the SNAP algorithm.

Parameters:
gGraph

Graph to be summarized.

vpropslist of VertexPropertyMap

Vertex attributes; only vertices with equal values are aggregated.

epropslist of EdgePropertyMap (optional, default: [])

Edge attributes, whose values define the edge types.

Returns:
sGraph

The summary graph, with one vertex per group, and one edge per pair of groups and edge type that occur in g (for directed graphs, per ordered pair).

bVertexPropertyMap

Group of every vertex of g, i.e. the corresponding vertex of s.

svpropslist of VertexPropertyMap

Values of vprops for the vertices of s.

sepropslist of EdgePropertyMap

Values of eprops for the edges of s (only if eprops is not empty).

See also

condensation_graph

Condensation of vertices with equal labels

dedensify

Compression with compressor vertices

Notes

The SNAP algorithm of Tian, Hankins, and Patel [tian-efficient-2008] starts by grouping the vertices with equal values of vprops, and splits the groups until all vertices of every group have (out-)neighbors, with every edge type, in the same set of groups. The result is the coarsest such partition, which is unique; it is computed here by refining all groups simultaneously, which leads to the same partition as splitting the groups one at a time, up to the numbering of the groups, which are numbered here in the order of their first vertex. Every iteration takes time \(O(N\log N + E\log E)\), and at most \(N\) iterations are needed.

References

[tian-efficient-2008]

Yuanyuan Tian, Richard A. Hankins and Jignesh M. Patel, “Efficient aggregation for graph summarization”, in Proceedings of the 2008 ACM SIGMOD International Conference on Management of Data, 567-580 (2008), DOI: 10.1145/1376616.1376675 [sci-hub, @tor]

Examples

>>> g = gt.collection.data["karate"]
>>> x = g.new_vp("int", vals=g.degree_property_map("total").a > 5)
>>> s, b, svprops = gt.snap_aggregation(g, [x])
>>> print(s.num_vertices(), s.num_edges())
27 64