java.lang.Object
org.jgrapht.generate.GnpRandomBipartiteGraphGenerator<V,E>
- Type Parameters:
V
- the graph vertex typeE
- the graph edge type
- All Implemented Interfaces:
GraphGenerator<V,E,V>
public class GnpRandomBipartiteGraphGenerator<V,E> extends java.lang.Object implements GraphGenerator<V,E,V>
Create a random bipartite graph based on the $G(n, p)$ Erdős–Rényi model. See the Wikipedia
article for details and references about
Random Graphs and the
Erdős–Rényi model
.
The user provides the sizes $n_1$ and $n_2$ of the two partitions $(n1+n2=n)$ and the probability
$p$ of the existence of an edge. The generator supports both directed and undirected graphs.
- Author:
- Dimitrios Michail
- See Also:
GnmRandomBipartiteGraphGenerator
-
Constructor Summary
Constructors Constructor Description GnpRandomBipartiteGraphGenerator(int n1, int n2, double p)
Create a new random bipartite graph generator.GnpRandomBipartiteGraphGenerator(int n1, int n2, double p, long seed)
Create a new random bipartite graph generator.GnpRandomBipartiteGraphGenerator(int n1, int n2, double p, java.util.Random rng)
Create a new random bipartite graph generator. -
Method Summary
Modifier and Type Method Description void
generateGraph(Graph<V,E> target, java.util.Map<java.lang.String,V> resultMap)
Generates a random bipartite graph.java.util.Set<V>
getFirstPartition()
Returns the first partition of vertices in the bipartite graph.java.util.Set<V>
getSecondPartition()
Returns the second partitions of vertices in the bipartite graph.
-
Constructor Details
-
GnpRandomBipartiteGraphGenerator
public GnpRandomBipartiteGraphGenerator(int n1, int n2, double p)Create a new random bipartite graph generator. The generator uses the $G(n, p)$ model when $n = n_1 + n_2$ and the bipartite graph has one partition with size $n_1$ and one partition with size $n_2$. An edge between two vertices of different partitions is included with probability $p$ independent of all other edges.- Parameters:
n1
- number of vertices of the first partitionn2
- number of vertices of the second partitionp
- edge probability
-
GnpRandomBipartiteGraphGenerator
public GnpRandomBipartiteGraphGenerator(int n1, int n2, double p, long seed)Create a new random bipartite graph generator. The generator uses the $G(n, p)$ model when $n = n_1 + n_2$, the bipartite graph has partition with size $n_1$ and a partition with size $n_2$. An edge between two vertices of different partitions is included with probability $p$ independent of all other edges.- Parameters:
n1
- number of vertices of the first partitionn2
- number of vertices of the second partitionp
- edge probabilityseed
- seed for the random number generator
-
GnpRandomBipartiteGraphGenerator
public GnpRandomBipartiteGraphGenerator(int n1, int n2, double p, java.util.Random rng)Create a new random bipartite graph generator. The generator uses the $G(n, p)$ model when $n = n_1 + n_2$, the bipartite graph has partition with size $n_1$ and a partition with size $n_2$. An edge between two vertices of different partitions is included with probability $p$ independent of all other edges.- Parameters:
n1
- number of vertices of the first partitionn2
- number of vertices of the second partitionp
- edge probabilityrng
- random number generator
-
-
Method Details
-
generateGraph
Generates a random bipartite graph.- Specified by:
generateGraph
in interfaceGraphGenerator<V,E,V>
- Parameters:
target
- the target graphresultMap
- not used by this generator, can be null
-
getFirstPartition
Returns the first partition of vertices in the bipartite graph. This partition is guaranteed to be smaller than or equal in size to the second partition.- Returns:
- one partition of the bipartite graph
-
getSecondPartition
Returns the second partitions of vertices in the bipartite graph. This partition is guaranteed to be larger than or equal in size to the first partition.- Returns:
- one partition of the bipartite graph
-