MCPcopy Index your code
hub / github.com/networkx/networkx / k_random_intersection_graph

Function k_random_intersection_graph

networkx/generators/intersection.py:53–84  ·  view source on GitHub ↗

Returns a intersection graph with randomly chosen attribute sets for each node that are of equal size (k). Parameters ---------- n : int The number of nodes in the first bipartite set (nodes) m : int The number of nodes in the second bipartite set (attributes)

(n, m, k, seed=None)

Source from the content-addressed store, hash-verified

51@py_random_state(3)
52@nx._dispatchable(graphs=None, returns_graph=True)
53def k_random_intersection_graph(n, m, k, seed=None):
54 """Returns a intersection graph with randomly chosen attribute sets for
55 each node that are of equal size (k).
56
57 Parameters
58 ----------
59 n : int
60 The number of nodes in the first bipartite set (nodes)
61 m : int
62 The number of nodes in the second bipartite set (attributes)
63 k : float
64 Size of attribute set to assign to each node.
65 seed : integer, random_state, or None (default)
66 Indicator of random number generation state.
67 See :ref:`Randomness<randomness>`.
68
69 See Also
70 --------
71 gnp_random_graph, uniform_random_intersection_graph
72
73 References
74 ----------
75 .. [1] Godehardt, E., and Jaworski, J.
76 Two models of random intersection graphs and their applications.
77 Electronic Notes in Discrete Mathematics 10 (2001), 129--132.
78 """
79 G = nx.empty_graph(n + m)
80 mset = range(n, n + m)
81 for v in range(n):
82 targets = seed.sample(mset, k)
83 G.add_edges_from(zip([v] * len(targets), targets))
84 return nx.projected_graph(G, range(n))
85
86
87@py_random_state(3)

Callers

nothing calls this directly

Calls 2

sampleMethod · 0.80
add_edges_fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…