This module handles compatibility between NetworKit and NetworkX


Convert a networKit.Graph to a networkx.Graph.


nkG (networkit.Graph) – The input NetworKit graph.

networkit.nxadapter.nx2nk(nxG, weightAttr=None)

Convert a networkx.Graph to a networkit.Graph. If data is true, try to convert networkx.Graph data to networkit.Graph attributes. Note that there are limitations to this conversion: networkit only supports int, float, and str attribute types. Other types will be converted into their string representation. Attribute keys are always converted to strings. Optionally, a dictionary that maps attribute names to specific types can be supplied.

  • nxG (networkx.Graph) – The input networkx graph.

  • weightAttr (str, optional) – The edge attribute which should be treated as the edge weight. Default: None

  • data (bool, optional) – If true, convert networkx.Graph data into networkit.Graph attributes. Default: False

  • typeMap (dict, optional) – Specifies the data type an attribute has. Missing attributes are inferred as described above. Default: None