V
- the graph vertex typeE
- the graph edge typepublic class BarabasiAlbertForestGenerator<V,E> extends Object implements GraphGenerator<V,E,V>
The general graph generator is described in the paper: A.-L. Barabási and R. Albert. Emergence of scaling in random networks. Science, 286:509-512, 1999.
The generator starts with a $t$ isolated nodes and grows the network by adding $n - t$ additional nodes. The additional nodes are added one by one and each of them is connected to one previously added node, where the probability of connecting to a node is proportional to its degree.
Note that this Barabàsi-Albert generator only works on undirected graphs. For a version that
works on both directed and undirected graphs and generates only connected graphs see
BarabasiAlbertGraphGenerator
.
Constructor and Description |
---|
BarabasiAlbertForestGenerator(int t,
int n)
Constructor
|
BarabasiAlbertForestGenerator(int t,
int n,
long seed)
Constructor
|
BarabasiAlbertForestGenerator(int t,
int n,
Random rng)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
generateGraph(Graph<V,E> target,
Map<String,V> resultMap)
Generates an instance.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
generateGraph
public BarabasiAlbertForestGenerator(int t, int n)
t
- number of treesn
- final number of nodesIllegalArgumentException
- in case of invalid parameterspublic BarabasiAlbertForestGenerator(int t, int n, long seed)
t
- number of treesn
- final number of nodesseed
- seed for the random number generatorIllegalArgumentException
- in case of invalid parameterspublic BarabasiAlbertForestGenerator(int t, int n, Random rng)
t
- number of treesn
- final number of nodesrng
- the random number generator to useIllegalArgumentException
- in case of invalid parameterspublic void generateGraph(Graph<V,E> target, Map<String,V> resultMap)
Note: An exception will be thrown if the target graph is not empty (i.e. contains at least one vertex)
generateGraph
in interface GraphGenerator<V,E,V>
target
- the target graphresultMap
- not used by this generator, can be nullNullPointerException
- if target
is null
IllegalArgumentException
- if target
is not undirectedIllegalArgumentException
- if target
is not emptyCopyright © 2018. All rights reserved.