Bases: object
Wrapper class that calls the BTER graph generator implementation in FEASTPACK from http://www.sandia.gov/~tgkolda/feastpack/ using GNU Octave.
Note that BTER needs the rng method which is unavailable in Octave, but the call in bter.m can be easily replaced.
Fit model to input graph
G (networkit.Graph) – The input graph.
scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1
A new scaled graph.
networkit.Graph
Generate graph.
Helper function for fit. Sets an output folder for writing the result to.
feastpackPath (str) – String containing a path.
Bases: StaticGraphGenerator
This generator implements the preferential attachment model as introduced by Barabasi and Albert[1]. The original algorithm is very slow and thus, the much faster method from Batagelj and Brandes[2] is implemented and the current default. The original method can be chosen by setting p batagelj to false. [1] Barabasi, Albert: Emergence of Scaling in Random Networks http://arxiv.org/pdf/cond-mat/9910332.pdf [2] ALG 5 of Batagelj, Brandes: Efficient Generation of Large Random Networks https://kops.uni-konstanz.de/bitstream/handle/123456789/5799/random.pdf?sequence=1
k (int) – Number of edges that come with a new node.
nMax (int) – Maximum number of nodes produced.
n0 (int or networkit.Graph) – Number of starting nodes or the initial starting graph. Default: 0
batagelj (bool) – Specifies whether to use batagelj’s method or the original one. Default: True
Fit model to input graph
G (networkit.Graph) – The input graph.
scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1
A new scaled graph.
networkit.Graph
Bases: StaticGraphGenerator
Given an arbitrary degree sequence, the Chung-Lu generative model will produce a random graph with the same expected degree sequence.
see Chung, Lu: The average distances in random graphs with given expected degrees and Chung, Lu: Connected Components in Random Graphs with Given Expected Degree Sequences. Aiello, Chung, Lu: A Random Graph Model for Massive Graphs describes a different generative model which is basically asymptotically equivalent but produces multi-graphs.
degreeSequence (list(float)) – Input degree sequence used to generate the graph.
Fit model to input graph
G (networkit.Graph) – The input graph.
scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1
A new scaled graph.
networkit.Graph
Bases: StaticGraphGenerator
The ClusteredRandomGraphGenerator class is used to create a clustered random graph.
The number of nodes and the number of edges are adjustable as well as the probabilities for intra-cluster and inter-cluster edges.
In parallel the generated graph is not deterministic. To ensure determinism, use a single thread.
n (int) – Number of nodes.
k (int) – Number of clusters.
pin (float) – Intra-cluster edge probability.
pout (float) – Inter-cluster edge probability.
Returns the generated ground truth clustering.
The generated ground truth clustering.
networkit.Partition
alias of EdgeSwitchingMarkovChainGenerator
Bases: StaticGraphGenerator
Generates a graph according to the Dorogovtsev-Mendes model.
nNodes (int) – Number of nodes in the target graph.
Fit model to input graph
G (networkit.Graph) – The input graph.
scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1
A new scaled graph.
networkit.Graph
Bases: object
Generates a graph according to the Dorogovtsev-Mendes model.
Generate event stream.
nSteps (int) – Number of time steps in the event stream.
List of graph events.
Bases: object
Generates a graph according to the forest fire model. The forest fire generative model produces dynamic graphs with the properties heavy tailed, degree distribution communities, densification, power law, shrinking diameter.
See Leskovec, Kleinberg, Faloutsos: Graphs over Tim: Densification Laws, Shringking Diameters and Possible Explanations
p (float) – Forward burning probability.
directed (bool) – Decides whether the resulting graph should be directed.
r (float, optional) – Backward burning probability. Default 1.0
Generate event stream.
nSteps (int) – Number of time steps in the event stream.
List of graph events.
Bases: object
Dynamic graph generator according to the hyperbolic unit disk model.
numNodes (int) – Number of nodes.
avgDegree (float) – Average degree of the resulting graph. Default: 6.0
gamma (float) – Power-law exponent of the resulting graph. Default: 3.0
T (float) – Temperature, selecting a graph family on the continuum between hyperbolic unit disk graphs and Erdos-Renyi graphs. Default: 0.0
moveEachStep (float) – Fraction of nodes to be moved in each time step. The nodes are chosen randomly each step. Default: 1.0
moveDistance (float) – Base value for the node movements. Default: 0.1
Generate event stream.
nSteps (int) – Number of time steps in the event stream.
List of graph events.
Get coordinates in the Poincare disk.
2D coordinates for every node in the graph.
list(tuple(float,float))
Return current graph.
The current graph.
networkit.Graph
Bases: object
Example dynamic graph generator: Generates a dynamically growing path.
Generate event stream.
nSteps (int) – Number of time steps in the event stream.
List of graph events.
Bases: object
Dynamic variant of networkit.generators.PubWebGenerator.
numNodes (int) – Up to a few thousand (possibly more if visualization is not desired and quadratic time complexity has been resolved)
numberOfDenseAreas (int) – Depending on number of nodes, e.g. [8, 50]
neighborhoodRadius (float) – The higher, the better the connectivity [0.1, 0.35]
maxNumberOfNeighbors (int) – Maximum degree, a higher value corresponds to better connectivity [4, 40]
Generate event stream.
nSteps (int) – Number of time steps in the event stream.
List of graph events.
Returns a list of coordinates from the current state.
2D coordinates of all nodes in the graph.
list(tuple(float,float))
Returns current graph
The resulting graph.
networkit.Graph
Get list of nodes and coordinates of points added during last generate call.
List of node ids and corresponding coordinates.
list(int, tuple(float,float))
Bases: StaticGraphGenerator
Graph generator for generating a random simple graph with exactly the given degree sequence based on the Edge-Switching Markov-Chain method.
This implementation is based on the paper “Random generation of large connected simple graphs with prescribed degree distribution” by Fabien Viger and Matthieu Latapy, available at http://www-rp.lip6.fr/~latapy/FV/generation.html, however without preserving connectivity (this could later be added as optional feature).
The Havel-Hakami generator is used for the initial graph generation, then the Markov-Chain Monte-Carlo algorithm as described and implemented by Fabien Viger and Matthieu Latapy but without the steps for ensuring connectivity is executed. This should lead to a graph that is drawn uniformly at random from all graphs with the given degree sequence.
Note that at most 10 times the number of edges edge swaps are performed (same number as in the abovementioned implementation) and in order to limit the running time, at most 200 times as many attempts to perform an edge swap are made (as certain degree distributions do not allow edge swaps at all).
degreeSequence (list(int)) – The degree sequence that shall be generated.
ignoreIfNotRealizable (bool, optional) – If true, generate the graph even if the degree sequence is not realizable. Some nodes may get lower degrees than requested in the sequence. Default: False
numSwitchesPerEdge (int, optional) – Average number of edge switches per edge produced. Default: 10
Fit model to input graph
G (networkit.Graph) – The input graph.
scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1
A new scaled graph.
networkit.Graph
Get realizable state without testing.
Indicator for realizable degree sequence.
bool
Test if degree sequence is realizable.
Indicator for realizable degree sequence.
bool
Bases: StaticGraphGenerator
Creates random graphs in the G(n,p) model. The generation follows Vladimir Batagelj and Ulrik Brandes: “Efficient generation of large random networks”, Phys Rev E 71, 036113 (2005).
Creates G(nNodes, prob) graphs.
nNodes (int) – Number of nodes n in the graph.
prob (float) – Probability of existence for each edge p.
directed (bool, optional) – Generates a directed graph. Default: False.
selfLoops (bool, optional) – Allows self-loops to be generated (only for directed graphs). Default: False.
Fit model to input graph
G (networkit.Graph) – The input graph.
scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1
A new scaled graph.
networkit.Graph
Bases: StaticGraphGenerator
Havel-Hakimi algorithm for generating a graph according to a given degree sequence.
The sequence, if it is realizable, is reconstructed exactly. The resulting graph usually has a high clustering coefficient. Construction runs in linear time O(m).
If the sequence is not realizable, depending on the parameter ignoreIfRealizable, either an exception is thrown during generation or the graph is generated with a modified degree sequence, i.e. not all nodes might have as many neighbors as requested.
sequence (list(int)) – Degree sequence to realize. Must be non-increasing.
ignoreIfRealizable (bool, optional) – If True, generate the graph even if the degree sequence is not realizable. Some nodes may get lower degrees than requested in the sequence. Default: True
Get realizable state without testing.
Indicator for realizable degree sequence.
bool
Test if degree sequence is realizable.
Indicator for realizable degree sequence.
bool
Bases: StaticGraphGenerator
The Hyperbolic Generator distributes points in hyperbolic space and adds edges between points with a probability depending on their distance. The resulting graphs have a power-law degree distribution, small diameter and high clustering coefficient. For a temperature of 0, the model resembles a unit-disk model in hyperbolic space.
n (int) – Number of nodes.
k (float, optional) – Average degree. Default: 6.0
gamma (float, optional) – Exponent of power-law degree distribution. Default: 3.0
T (float, optional) – Temperature of statistical model. Default: 0.0
Fit model to input graph
G (networkit.Graph) – The input graph.
scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1
A new scaled graph.
networkit.Graph
Generate a graph with overriding parameters.
angles (list(float)) – List with angles of node positions.
radii (list(float)) – List with radii of node positions.
R (float) – Radius of poincare disk to place nodes in.
T (float, optional) – Edges are added for nodes closer to each other than threshold T. Default: 0.0
Get running time of generator for each.
Running time of the generator for each thread.
list(float)
Set the balance of the quadtree. Value should be between 0.0 and 1.0. Without modification this is set to 0.5.
balance (float) – Balance factor between 0.0 and 1.0.
Set the capacity of a quadtree leaf.
capacity (int) – Tuning parameter.
When using a theoretically optimal split, the quadtree will be flatter, but running time usually longer.
theoreticalSplit (bool) – Whether to use the theoretically optimal split. Default: False.
Bases: Algorithm
The LFR clustered graph generator as introduced by Andrea Lancichinetti, Santo Fortunato, and Filippo Radicchi.
The community assignment follows the algorithm described in “Benchmark graphs for testing community detection algorithms”. The edge generation is however taken from their follow-up publication “Benchmarks for testing community detection algorithms on directed and weighted graphs with overlapping communities”. Parts of the implementation follow the choices made in their implementation which is available at https://sites.google.com/site/andrealancichinetti/software but other parts differ, for example some more checks for the realizability of the community and degree size distributions are done instead of heavily modifying the distributions.
The edge-switching markov-chain algorithm implementation in NetworKit is used which is different from the implementation in the original LFR benchmark.
You need to set a degree sequence, a community size sequence and a mu using the additionally provided set- or generate-methods.
n (int) – The number of nodes.
Fit model to input graph
G (networkit.Graph) – The input graph.
scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1
vanilla (bool, optional) – If set to True, fit power law to degree distribution. Otherwise fit to community sequence.
communityDetectionAlgorithm (nk.community.CommunityDetector, optional) – Community detection algorithm used for fitting. Default: nk.community.PLM
plfit (bool, optional) – If set to True, power law fitting is enabled. Default: False
A new scaled graph.
networkit.Graph
Generates and returns the graph. Wrapper for the StaticGraphGenerator interface.
useReferenceImplementation (bool) – Sets whether the reference implmentation should be used for generating. Default: False
The generated graph.
networkit.Graph
Generate a powerlaw community size sequence with the given minimum and maximum size and the given exponent.
minCommunitySize (int) – The minimum community size.
maxCommunitySize (int) – The maximum community size.
communitySizeExp (float) – The (negative) community size exponent of the power law degree distribution of the community sizes.
Generate and set a power law degree sequence using the given average and maximum degree with the given exponent.
avgDegree (int) – The average degree of the created graph.
maxDegree (int) – The maximum degree of the created graph.
nodeDegreeExp (float) – The (negative) exponent of the power law degree distribution of the node degrees.
Return the generated Graph.
The generated graph.
networkit.Graph
Return the generated Partiton.
The generated partition.
networkit.Partition
Set the given community size sequence.
communitySizeSequence (list(float)) – The community sizes that shall be used.
Set the given degree sequence.
degreeSequence (list(int)) – The degree sequence that shall be used by the generator.
Set the mixing parameter, this is the fraction of neighbors of each node that do not belong to the node’s own community.
This can either be one value for all nodes or an iterable of values for each node.
mu (float or list(float)) – The mixing coefficient(s), i.e. the factor of the degree that shall be inter-cluster degree
Set the internal degree of each node using a binomial distribution such that the expected mixing parameter is the given @a mu.
The mixing parameter is for each node the fraction of neighbors that do not belong to the node’s own community.
mu (float) – The expected mu that shall be used.
Set the partition, this replaces the community size sequence and the random assignment of the nodes to communities.
zeta (networkit.Partition) – The partition to use.
Helper function for fit. Sets an output folder for writing the result to.
path (str) – String containing a path.
Bases: StaticGraphGenerator
Creates random spatial graphs according to the Mocnik model (improved algorithm).
Please cite the following publications, in which you will find a description of the model:
Franz-Benjamin Mocnik: “The Polynomial Volume Law of Complex Networks in the Context of Local and Global Optimization”, Scientific Reports 8(11274) 2018. doi: 10.1038/s41598-018-29131-0
Franz-Benjamin Mocnik, Andrew Frank: “Modelling Spatial Structures”, Proceedings of the 12th Conference on Spatial Information Theory (COSIT), 2015, pages 44-64. doi: 10.1007/978-3-319-23374-1_3
dim (int) – Dimension of the space.
n (int) – Number of nodes in the graph; or a list containing the numbers of nodes in each layer in case of a hierarchical model.
k (float) – Density parameter, determining the ratio of edges to nodes; in case of a hierarchical model, also a list of density parameters can be provided.
weighted (bool, optional) – Determines whether weights should be added to the edges; in case of a hierarchical model, also a list of relative weights can be provided. Default: False
Bases: StaticGraphGenerator
Creates random spatial graphs according to the Mocnik model (non-improved algorithm).
Please cite the following publications, in which you will find a description of the model:
Franz-Benjamin Mocnik: “The Polynomial Volume Law of Complex Networks in the Context of Local and Global Optimization”, Scientific Reports 8(11274) 2018. doi: 10.1038/s41598-018-29131-0
Franz-Benjamin Mocnik, Andrew Frank: “Modelling Spatial Structures”, Proceedings of the 12th Conference on Spatial Information Theory (COSIT), 2015, pages 44-64. doi: 10.1007/978-3-319-23374-1_3
dim (int) – Dimension of the space.
n (int) – Number of nodes in the graph.
k (float) – Density parameter, determining the ratio of edges to nodes.
Bases: object
Other calling possibilities:
PowerlawDegreeSequence(G)
PowerlawDegreeSequence(degreeSequence)
Generates a powerlaw degree sequence with the given minimum and maximum degree, the powerlaw exponent gamma
If a list of degrees or a graph is given instead of a minimum degree, the class uses the minimum and maximum value of the sequence and fits the exponent such that the expected average degree is the actual average degree.
minDeg (int) – The minium degree.
maxDeg (int, optional) – The maximum degree.
gamma (float, optional) – The powerlaw exponent. Default: -2.0
G (networkit.Graph, alternative) – The input graph.
degreeSequence (list(int), alternative) – List of degrees to fit.
Returns a degree drawn at random with a power law distribution.
The generated random degree.
int
Returns a degree sequence with even degree sum.
numNodes (int) – The number of nodes/degrees that shall be returned.
The generated degree sequence.
list(int)
Returns the expected average degree. Note: run needs to be called first.
The expected average degree.
float
Get the exponent gamma.
The exponent gamma.
float
Get the maximum degree
The maximum degree
int
Returns the minimum degree.
The minimum degree.
int
Executes the generation of the probability distribution.
Set the exponent gamma.
gamma (float) – The exponent to set.
Tries to set the powerlaw exponent gamma such that the specified average degree is expected.
avgDeg (float) – The average degree that shall be approximated.
minGamma (float, optional) – The minimum gamma to use. Default: -1.0
maxGamma (float, optional) – The maximum gamma to use. Default: -6.0
Tries to set the minimum degree such that the specified average degree is expected.
avgDeg (float) – The average degree that shall be approximated.
Bases: StaticGraphGenerator
Generates a static graph that resembles an assumed geometric distribution of nodes in a P2P network.
The basic structure is to distribute points randomly in the unit torus and to connect vertices close to each other (at most @a neighRad distance and none of them already has @a maxNeigh neighbors). The distribution is chosen to get some areas with high density and others with low density. There are @a numDenseAreas dense areas, which can overlap. Each area is circular, has a certain position and radius and number of points. These values are strored in @a denseAreaXYR and @a numPerArea, respectively.
Used and described in more detail in J. Gehweiler, H. Meyerhenke: A Distributed Diffusive Heuristic for Clustering a Virtual P2P Supercomputer. In Proc. 7th High-Performance Grid Computing Workshop (HPGC’10), in conjunction with 24th IEEE Internatl. Parallel and Distributed Processing Symposium (IPDPS’10), IEEE, 2010.
numNodes (int) – Up to a few thousand (possibly more if visualization is not desired and quadratic time complexity has been resolved)
numberOfDenseAreas (int) – Depending on number of nodes, e.g. [8, 50]
neighborhoodRadius (float) – The higher, the better the connectivity [0.1, 0.35]
maxNumberOfNeighbors (int) – Maximum degree, a higher value corresponds to better connectivity [4, 40]
Returns a list of coordinates
2D coordinates of all nodes in the graph.
list(tuple(float,float))
Bases: StaticGraphGenerator
Constructs a regular ring lattice.
nNodes (int) – Number of nodes in the target graph.
nNeighbors (int) – Number of neighbors on each side of a node.
Bases: StaticGraphGenerator
Generates static R-MAT graphs. R-MAT (recursive matrix) graphs are random graphs with n=2^scale nodes and m=nedgeFactor edges. More details at http://www.graph500.org or in the original paper: Deepayan Chakrabarti, Yiping Zhan, Christos Faloutsos: R-MAT: A Recursive Model for Graph Mining. SDM 2004: 442-446.
scale (int) – Number of nodes = 2^scale
edgeFactor (int) – Number of edges = number of nodes * edgeFactor
a (float) – Probability for quadrant upper left
b (float) – Probability for quadrant upper right
c (float) – Probability for quadrant lower left
d (float) – Probability for quadrant lower right
weighted (bool, optional) – Indicates whether the resulting graph should be weighted. Default: False
reduceNodes (int, optional) – The number of nodes, which should be deleted from the generated graph. Default: 0
Fit model to input graph
G (networkit.Graph) – The input graph.
scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1
initiator (tuple(float, float, float, float), optional) – Initiate quadrants with custom values. Default: None
kronfit (bool, optional) – Indicates whether a slower but more accurate fitting functions is used. Default: True
iterations (int, optional) – Number of iterations. Default: 50
A new scaled graph.
networkit.Graph
Helper function for fit. Sets an output folder for writing the result to.
kronfitPath (str) – String containing a path.
Bases: object
Abstract base class for static graph generators
Generates the graph.
The generated graph.
networkit.Graph
Bases: StaticGraphGenerator
Generates a graph according to the Watts-Strogatz model.
First, a regular ring lattice is generated. Then edges are rewired with a given probability.
nNodes (int) – Number of nodes in the target graph.
nNeighbors (int) – Number of neighbors on each side of a node.
p (float) – Rewiring probability.