scglue.graph.collapse_multigraph

scglue.graph.collapse_multigraph(graph, merge_fns=None)[source]

Collapse multi-edges into simple-edges

Parameters
  • graph (MultiGraph) – Input multi-graph

  • merge_fns (Optional[Mapping[str, Callable]]) – Attribute-specific merge functions, indexed by attribute name. Each merge function should accept a list of values and return a single value.

Return type

Graph

Returns

collapsed – Collapsed graph

Note

The collapsed graph would be directed if the input graph is directed. Edges causing ValueError in merge_fns will be discarded.