random_triad#
- random_triad(G, seed=None)[source]#
Returns a random triad from a directed graph.
- 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)
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)])