Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

Ordered Graphs—Consistently ordered graphs

Consistently ordered variants of the default base classes.

The Ordered (Di/Multi/MultiDi) Graphs give a consistent order for reporting of nodes and edges. The order of node reporting agrees with node adding, but for edges, the order is not necessarily the order that the edges were added.

In general, you should use the default (i.e., unordered) graph classes. However, there are times (e.g., when testing) when you may need the order preserved.

class OrderedGraph(incoming_graph_data=None, **attr)[source]

Consistently ordered variant of Graph.

class OrderedDiGraph(incoming_graph_data=None, **attr)[source]

Consistently ordered variant of DiGraph.

class OrderedMultiGraph(incoming_graph_data=None, **attr)[source]

Consistently ordered variant of MultiGraph.

class OrderedMultiDiGraph(incoming_graph_data=None, **attr)[source]

Consistently ordered variant of MultiDiGraph.