easygraph.functions.graph_generator.RandomNetwork module#
- easygraph.functions.graph_generator.RandomNetwork.WS_Random(n, k, p, FilePath=None)[source]#
Returns a small-world graph.
- Parameters:
n (int) – The number of nodes
k (int) – Each node is joined with its k nearest neighbors in a ring topology.
p (float) – The probability of rewiring each edge
FilePath (string) – The file for storing the output graph G
- Returns:
G – a small-world graph
- Return type:
graph
Examples
Returns a small-world graph G
>>> WS_Random(100,10,0.3,"/users/fudanmsn/downloads/RandomNetwork.txt")
- easygraph.functions.graph_generator.RandomNetwork.erdos_renyi_M(n, edge, directed=False, FilePath=None)[source]#
Given the number of nodes and the number of edges, return an Erdős-Rényi random graph, and store the graph in a document.
- Parameters:
n (int) – The number of nodes.
edge (int) – The number of edges.
directed (bool, optional (default=False)) – If True, this function returns a directed graph.
FilePath (string) – The file for storing the output graph G.
- Returns:
G – an Erdős-Rényi random graph.
- Return type:
graph
Examples
Returns an Erdős-Rényi random graph G.
>>> erdos_renyi_M(100,180,directed=False,FilePath="/users/fudanmsn/downloads/RandomNetwork.txt")
References
[1]Erdős and A. Rényi, On Random Graphs, Publ. Math. 6, 290 (1959).
[2]Gilbert, Random Graphs, Ann. Math. Stat., 30, 1141 (1959).
- easygraph.functions.graph_generator.RandomNetwork.erdos_renyi_P(n, p, directed=False, FilePath=None)[source]#
Given the number of nodes and the probability of edge creation, return an Erdős-Rényi random graph, and store the graph in a document.
- Parameters:
n (int) – The number of nodes.
p (float) – Probability for edge creation.
directed (bool, optional (default=False)) – If True, this function returns a directed graph.
FilePath (string) – The file for storing the output graph G.
- Returns:
G – an Erdős-Rényi random graph.
- Return type:
graph
Examples
Returns an Erdős-Rényi random graph G
>>> erdos_renyi_P(100,0.5,directed=False,FilePath="/users/fudanmsn/downloads/RandomNetwork.txt")
References
[1]Erdős and A. Rényi, On Random Graphs, Publ. Math. 6, 290 (1959).
[2]Gilbert, Random Graphs, Ann. Math. Stat., 30, 1141 (1959).
- easygraph.functions.graph_generator.RandomNetwork.fast_erdos_renyi_P(n, p, directed=False, FilePath=None)[source]#
Given the number of nodes and the probability of edge creation, return an Erdős-Rényi random graph, and store the graph in a document. Use this function for generating a huge scale graph.
- Parameters:
n (int) – The number of nodes.
p (float) – Probability for edge creation.
directed (bool, optional (default=False)) – If True, this function returns a directed graph.
FilePath (string) – The file for storing the output graph G.
- Returns:
G – an Erdős-Rényi random graph.
- Return type:
graph
Examples
Returns an Erdős-Rényi random graph G
>>> erdos_renyi_P(100,0.5,directed=False,FilePath="/users/fudanmsn/downloads/RandomNetwork.txt")
References
[1]Erdős and A. Rényi, On Random Graphs, Publ. Math. 6, 290 (1959).
[2]Gilbert, Random Graphs, Ann. Math. Stat., 30, 1141 (1959).
- easygraph.functions.graph_generator.RandomNetwork.graph_Gnm(num_v: int, num_e: int)[source]#
Return a random graph with
num_v
vertices andnum_e
edges. Edges are drawn uniformly from the set of possible edges.- Parameters:
num_v (
int
) – The Number of vertices.num_e (
int
) – The Number of edges.
Examples
>>> import easygraph.randomhypergraph as rh >>> g = rh.graph_Gnm(4, 5) >>> g.e ([(1, 2), (0, 3), (2, 3), (0, 2), (1, 3)], [1.0, 1.0, 1.0, 1.0, 1.0])