Conversions

A small collection of utility methods in order to convert from/to other graph formats.

jgrapht.convert.from_nx(graph, any_hashable=True)[source]

Create a graph from a NetworkX graph.

Parameters
  • graph (nx graph) – a graph

  • any_hashable (boolean) – if true the returned graph uses the same objects as the nx graph, otherwise integers are used. In the later case a renumbering is performed independently from any possible ordering in the original graph.

Returns

a new graph

Type

jgrapht graph

jgrapht.convert.from_pydot(graph)[source]

Create a graph from a pydot graph.

Parameters

graph (pydot graph) – a graph

Returns

a new graph

Return type

jgrapht graph

jgrapht.convert.to_nx(graph)[source]

Create a NetworkX graph from a graph.

Parameters

graph (jgrapht graph) – a graph

Returns

a new graph

Return type

NetworkX graph

jgrapht.convert.to_pydot(graph)[source]

Convert a graph to a pydot graph.

Parameters

graph (jgrapht graph) – a graph

Returns

a new graph

Return type

pydot graph