graph_tool.generation.remove_random_edges#

graph_tool.generation.remove_random_edges(g, M, weight=None, counts=True)[source]#

Remove edges from the graph, chosen uniformly at random.

Parameters:
gGraph

Graph to be modified.

Mint

Number of edges to be removed.

weightEdgePropertyMap, optional (default: None)

Integer edge multipliciites or edge removal probabilities. If supplied, and counts == True this will be decremented for edges removed.

countsbool, optional (default: True)

If True, the values given by weight are assumed to be integer edge multiplicities. Otherwise, they will be only considered to be proportional to the probability of an edge being removed.

See also

add_random_edges

add random edges to the graph

Notes

This algorithm runs in time \(O(E\left<k\right>)\) if weight is None, otherwise \(O(E + \left<k\right>M\log E)\).

Note

The complexity can be improved to \(O(E)\) and \(O(E + M\log E)\), respectively, if fast edge removal is activated via set_fast_edge_removal() prior to running this function.

Examples

>>> g = gt.lattice([100, 100])
>>> gt.remove_random_edges(g, 10000)
>>> gt.label_components(g)[1].max()
3371