expand_parallel_edges

expand_parallel_edges#

graph_tool.generation.expand_parallel_edges(g, weight)[source]#

Expand edge multiplicities into parallel edges.

Parameters:
gGraph

Graph to be modified.

weightEdgePropertyMap

Edge multiplicities.

See also

contract_parallel_edges

contract all parallel edges into simple edges.

Notes

This algorithm runs in time \(O(N + E)\) where \(N\) is the number of vertices and \(E\) is the final number of edges in the graph.

Parallel implementation.

If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.

Examples

>>> u = gt.collection.data["polblogs"].copy()
>>> u.set_directed(False)
>>> g = u.copy()
>>> w = gt.contract_parallel_edges(g)
>>> gt.expand_parallel_edges(g, w)
>>> gt.similarity(g, u)
1.0