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


stochastic_graph(G, copy=True, weight='weight')[source]

Return a right-stochastic representation of G.

A right-stochastic graph is a weighted digraph in which all of the node (out) neighbors edge weights sum to 1.

Parameters :

G : directed graph

A NetworkX DiGraph

copy : boolean, optional

If True make a copy of the graph, otherwise modify the original graph

weight : edge attribute key (optional, default=’weight’)

Edge data key used for weight. If no attribute is found for an edge the edge weight is set to 1. Weights must be positive numbers.