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 nodes and \(E\) is the final number of edges in the graph.

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