Warning
This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
stochastic_graph¶
-
stochastic_graph
(G, copy=True, weight='weight')[source]¶ Returns a right-stochastic representation of the directed graph
G
.A right-stochastic graph is a weighted digraph in which for each node, the sum of the weights of all the out-edges of that node is 1. If the graph is already weighted (for example, via a
'weight'
edge attribute), the reweighting takes that into account.- G : directed graph
- A NetworkX DiGraph
- copy : boolean, optional
- If this is
True
, then this function returns a new instance ofnetworkx.Digraph
. Otherwise, the original graph is modified in-place (and also returned, for convenience). - weight : edge attribute key (optional, default=’weight’)
- Edge attribute key used for reading the existing weight and setting the new weight. If no attribute with this key is found for an edge, then the edge weight is assumed to be 1. If an edge has a weight, it must be a a positive number.