random_triad#
- random_triad(G, seed=None)[source]#
Returns a random triad from a directed graph.
Deprecated since version 3.3: random_triad is deprecated and will be removed in version 3.5. Use random sampling directly instead:
G.subgraph(random.sample(list(G), 3))
- Parameters:
- Gdigraph
A NetworkX DiGraph
- seedinteger, random_state, or None (default)
Indicator of random number generation state. See Randomness.
- Returns:
- G2subgraph
A randomly selected triad (order-3 NetworkX DiGraph)
- Raises:
- NetworkXError
If the input Graph has less than 3 nodes.
Examples
>>> G = nx.DiGraph([(1, 2), (1, 3), (2, 3), (3, 1), (5, 6), (5, 4), (6, 7)]) >>> triad = nx.random_triad(G, seed=1) >>> triad.edges OutEdgeView([(1, 2)])