dedensify

Contents

dedensify#

graph_tool.generation.dedensify(g, threshold)[git][source]#

Compress a graph by replacing the edges to groups of high-degree vertices with compressor vertices.

Parameters:
gGraph

Graph to be compressed.

thresholdint

Vertices with (in-)degree larger than this value are considered high-degree. It must be at least 2.

Returns:
hGraph

The compressed graph, whose first vertices correspond to those of g, followed by the compressor vertices.

compressorVertexPropertyMap

Boolean vertex property map marking the compressor vertices.

See also

snap_aggregation

Summary by vertex aggregation

condensation_graph

Condensation of vertices with equal labels

Notes

In the dedensification of Maccioni and Abadi [maccioni-scalable-2016], the vertices with degree (in-degree, for directed graphs) larger than threshold are the high-degree vertices. The vertices with the same nonempty set \(H\) of high-degree (out-)neighbors form a group \(L\), and if \(|H||L| > |H| + |L|\), the edges from \(L\) to \(H\) are replaced by edges from every vertex of \(L\) to a new compressor vertex, and from it to every vertex of \(H\), so that the paths of length two through the compressor vertices encode the removed edges. The groups are processed in the order of their first vertex. The algorithm runs in time \(O(N + E\log E)\).

References

[maccioni-scalable-2016]

Antonio Maccioni and Daniel J. Abadi, “Scalable pattern matching over compressed graphs via dedensification”, in Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 1755-1764 (2016), DOI: 10.1145/2939672.2939856 [sci-hub, @tor]

Examples

>>> g = gt.Graph([(1, 0), (1, 2), (1, 3), (1, 4), (5, 0), (5, 2), (5, 3),
...               (5, 4), (6, 0), (6, 2), (6, 3), (6, 4)])
>>> h, c = gt.dedensify(g, 2)
>>> print(h.num_vertices(), h.num_edges(), c.a.sum())
8 7 1

The original and the compressed graphs are drawn as follows, with the compressor vertex highlighted:

>>> gt.graph_draw(g, pos=gt.sfdp_layout(g),
...               output="dedensify-original.pdf")
<...>
>>> cmap = matplotlib.colors.ListedColormap(["#cccccc", "#f28c8e"])
>>> gt.graph_draw(h, pos=gt.sfdp_layout(h), vertex_fill_color=c, vcmap=cmap,
...               output="dedensify-compressed.pdf")
<...>
../_images/dedensify-original.png

Directed graph before the dedensification.#

../_images/dedensify-compressed.png

Dedensified graph with a threshold of 2, with the compressor vertex in red.#