networkit.generators

class networkit.generators.BTERReplicator

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.

classmethod fit(G, scale=1)

Fit model to input graph

Parameters
  • G (networkit.Graph) – The input graph.

  • scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1

Returns

A new scaled graph.

Return type

networkit.Graph

generate()

Generate graph.

classmethod setPaths(feastpackPath)

Helper function for fit. Sets an output folder for writing the result to.

Parameters

feastpackPath (str) – String containing a path.

class networkit.generators.BarabasiAlbertGenerator(k, nMax, n0=0, batagelj=True)

Bases: networkit.generators.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

Parameters
  • k (int) – Number of edges that come with a new node.

  • nMax (int) – Maximum number of nodes produced.

  • n0 (int) – Number of starting nodes.

  • batagelj (bool) – Specifies whether to use batagelj’s method or the original one.

fit(G, scale=1)

Fit model to input graph

Parameters
  • G (networkit.Graph) – The input graph.

  • scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1

Returns

A new scaled graph.

Return type

networkit.Graph

class networkit.generators.ChungLuGenerator(degreeSequence)

Bases: networkit.generators.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.

Parameters

degreeSequence (list(float)) – Input degree sequence used to generate the graph.

fit(G, scale=1)

Fit model to input graph

Parameters
  • G (networkit.Graph) – The input graph.

  • scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1

Returns

A new scaled graph.

Return type

networkit.Graph

ClusteredRandomGraphGenerator(count, count, pin, pout)

Bases: networkit.generators.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.

Parameters
  • n (int) – Number of nodes.

  • k (int) – Number of clusters.

  • pin (float) – Intra-cluster edge probability.

  • pout (float) – Inter-cluster edge probability.

ClusteredRandomGraphGenerator.getCommunities()

Returns the generated ground truth clustering.

Returns

The generated ground truth clustering.

Return type

networkit.Partition

networkit.generators.ConfigurationModelGenerator

alias of networkit.generators.EdgeSwitchingMarkovChainGenerator

class networkit.generators.DorogovtsevMendesGenerator(nNodes)

Bases: networkit.generators.StaticGraphGenerator

Generates a graph according to the Dorogovtsev-Mendes model.

Parameters

nNodes (int) – Number of nodes in the target graph.

fit(G, scale=1)

Fit model to input graph

Parameters
  • G (networkit.Graph) – The input graph.

  • scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1

Returns

A new scaled graph.

Return type

networkit.Graph

class networkit.generators.DynamicDorogovtsevMendesGenerator

Bases: object

Generates a graph according to the Dorogovtsev-Mendes model.

generate(nSteps)

Generate event stream.

Parameters

nSteps (int) – Number of time steps in the event stream.

Returns

List of graph events.

Return type

list(networkit.dynamics.GraphEvent)

class networkit.generators.DynamicForestFireGenerator(p, directed, r=1.0)

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

Parameters
  • p (float) – Forward burning probability.

  • directed (bool) – Decides whether the resulting graph should be directed.

  • r (float, optional) – Backward burning probability.

generate(nSteps)

Generate event stream.

Parameters

nSteps (int) – Number of time steps in the event stream.

Returns

List of graph events.

Return type

list(networkit.dynamics.GraphEvent)

class networkit.generators.DynamicHyperbolicGenerator(numNodes, avgDegree=6.0, gamma=3.0, T=0.0, moveEachStep=1.0, moveDistance=0.1)

Bases: object

Dynamic graph generator according to the hyperbolic unit disk model.

Parameters
  • numNodes (int) – Number of nodes.

  • avgDegree (float) – Average degree of the resulting graph.

  • gamma (float) – Power-law exponent of the resulting graph.

  • T (float) – Temperature, selecting a graph family on the continuum between hyperbolic unit disk graphs and Erdos-Renyi graphs.

  • moveEachStep (float) – Fraction of nodes to be moved in each time step. The nodes are chosen randomly each step.

  • moveDistance (float) – Base value for the node movements.

generate(nSteps)

Generate event stream.

Parameters

nSteps (int) – Number of time steps in the event stream.

Returns

List of graph events.

Return type

list(networkit.dynamics.GraphEvent)

getCoordinates()

Get coordinates in the Poincare disk.

Returns

2D coordinates for every node in the graph.

Return type

list(tuple(float,float))

getGraph()

Return current graph.

Returns

The current graph.

Return type

networkit.Graph

class networkit.generators.DynamicPathGenerator

Bases: object

Example dynamic graph generator: Generates a dynamically growing path.

generate(nSteps)

Generate event stream.

Parameters

nSteps (int) – Number of time steps in the event stream.

Returns

List of graph events.

Return type

list(networkit.dynamics.GraphEvent)

class networkit.generators.DynamicPubWebGenerator(numNodes, numberOfDenseAreas, neighborhoodRadius, maxNumberOfNeighbors)

Bases: object

Dynamic variant of networkit.generators.PubWebGenerator.

Parameters
  • 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(nSteps)

Generate event stream.

Parameters

nSteps (int) – Number of time steps in the event stream.

Returns

List of graph events.

Return type

list(networkit.dynamics.GraphEvent)

getCoordinates()

Returns a list of coordinates from the current state.

Returns

2D coordinates of all nodes in the graph.

Return type

list(tuple(float,float))

getGraph()

Returns current graph

Returns

The resulting graph.

Return type

networkit.Graph

getNewCoordinates()

Get list of nodes and coordinates of points added during last generate call.

Returns

List of node ids and corresponding coordinates.

Return type

list(int, tuple(float,float))

class networkit.generators.EdgeSwitchingMarkovChainGenerator(degreeSequence, ignoreIfNotRealizable=False, numSwitchesPerEdge=10)

Bases: networkit.generators.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).

Parameters
  • 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(G, scale=1)

Fit model to input graph

Parameters
  • G (networkit.Graph) – The input graph.

  • scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1

Returns

A new scaled graph.

Return type

networkit.Graph

getRealizable()

Get realizable state without testing.

Returns

Indicator for realizable degree sequence.

Return type

bool

isRealizable()

Test if degree sequence is realizable.

Returns

Indicator for realizable degree sequence.

Return type

bool

class networkit.generators.ErdosRenyiGenerator(count nNodes, double prob, directed = False, selfLoops = False)

Bases: networkit.generators.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.

Parameters
  • 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(G, scale=1)

Fit model to input graph

Parameters
  • G (networkit.Graph) – The input graph.

  • scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1

Returns

A new scaled graph.

Return type

networkit.Graph

class networkit.generators.HavelHakimiGenerator(sequence, ignoreIfRealizable=True)

Bases: networkit.generators.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.

Parameters
  • 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.

getRealizable()

Get realizable state without testing.

Returns

Indicator for realizable degree sequence.

Return type

bool

isRealizable()

Test if degree sequence is realizable.

Returns

Indicator for realizable degree sequence.

Return type

bool

class networkit.generators.HyperbolicGenerator(n, k=6, gamma=3, T=0)

Bases: networkit.generators.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.

Parameters
  • 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(G, scale=1)

Fit model to input graph

Parameters
  • G (networkit.Graph) – The input graph.

  • scale (int, optional) – Scale the maximum number of nodes by a factor. Default: 1

Returns

A new scaled graph.

Return type

networkit.Graph

generate_advanced(angles, radii, R, T=0)

Generate a graph with overriding parameters.

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

getElapsedMilliseconds()

Get running time of generator for each.

Returns

Running time of the generator for each thread.

Return type

list(float)

setBalance(balance)

Set the balance of the quadtree. Value should be between 0.0 and 1.0. Without modification this is set to 0.5.

Parameters

balance (float) – Balance factor between 0.0 and 1.0.

setLeafCapacity(capacity)

Set the capacity of a quadtree leaf.

Parameters

capacity (int) – Tuning parameter.

setTheoreticalSplit(theoreticalSplit)

When using a theoretically optimal split, the quadtree will be flatter, but running time usually longer.

Parameters

theoreticalSplit (bool) – Whether to use the theoretically optimal split. Default: False.

class networkit.generators.LFRGenerator(n)

Bases: networkit.base.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.

Parameters

n (int) – The number of nodes.

fit(G, scale=1, vanilla=False, communityDetectionAlgorithm=PLM, plfit=False)

Fit model to input graph

Parameters
  • 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

Returns

A new scaled graph.

Return type

networkit.Graph

generate(useReferenceImplementation=False)

Generates and returns the graph. Wrapper for the StaticGraphGenerator interface.

Parameters

useReferenceImplementation (bool) – Sets whether the reference implmentation should be used for generating.

Returns

The generated graph.

Return type

networkit.Graph

generatePowerlawCommunitySizeSequence(minCommunitySize, maxCommunitySize, communitySizeExp)

Generate a powerlaw community size sequence with the given minimum and maximum size and the given exponent.

Parameters
  • 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.

generatePowerlawDegreeSequence(avgDegree, maxDegree, nodeDegreeExp)

Generate and set a power law degree sequence using the given average and maximum degree with the given exponent.

Parameters
  • 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.

getGraph()

Return the generated Graph.

Returns

The generated graph.

Return type

networkit.Graph

getPartition()

Return the generated Partiton.

Returns

The generated partition.

Return type

networkit.Partition

setCommunitySizeSequence(communitySizeSequence)

Set the given community size sequence.

Parameters

communitySizeSequence (list(float)) – The community sizes that shall be used.

setDegreeSequence(degreeSequence)

Set the given degree sequence.

Parameters

degreeSequence (list(int)) – The degree sequence that shall be used by the generator.

setMu(mu)

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.

Parameters

mu (float or list(float)) – The mixing coefficient(s), i.e. the factor of the degree that shall be inter-cluster degree

setMuWithBinomialDistribution(mu)

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.

Parameters

mu (float) – The expected mu that shall be used.

setPartition(zeta)

Set the partition, this replaces the community size sequence and the random assignment of the nodes to communities.

Parameters

zeta (networkit.Partition) – The partition to use.

setPathToReferenceImplementationDir(path)

Helper function for fit. Sets an output folder for writing the result to.

Parameters

path (str) – String containing a path.

class networkit.generators.MocnikGenerator(dim, n, k, weighted)

Bases: networkit.generators.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

Parameters
  • 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

class networkit.generators.MocnikGeneratorBasic(dim, n, k)

Bases: networkit.generators.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

Parameters
  • 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.

class networkit.generators.PowerlawDegreeSequence(minDeg, maxDeg, gamma)

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.

Parameters
  • 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.

getDegree()

Returns a degree drawn at random with a power law distribution.

Returns

The generated random degree.

Return type

int

getDegreeSequence(numNodes)

Returns a degree sequence with even degree sum.

Parameters

numNodes (int) – The number of nodes/degrees that shall be returned.

Returns

The generated degree sequence.

Return type

list(int)

getExpectedAverageDegree()

Returns the expected average degree. Note: run needs to be called first.

Returns

The expected average degree.

Return type

float

getGamma()

Get the exponent gamma.

Returns

The exponent gamma.

Return type

float

getMaximumDegree()

Get the maximum degree

Returns

The maximum degree

Return type

int

getMinimumDegree()

Returns the minimum degree.

Returns

The minimum degree.

Return type

int

run()

Executes the generation of the probability distribution.

setGamma(gamma)

Set the exponent gamma.

Parameters

gamma (float) – The exponent to set.

setGammaFromAverageDegree(avgDeg, minGamma=- 1, maxGamma=- 6)

Tries to set the powerlaw exponent gamma such that the specified average degree is expected.

Parameters
  • 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

setMinimumFromAverageDegree(avgDeg)

Tries to set the minimum degree such that the specified average degree is expected.

Parameters

avgDeg (float) – The average degree that shall be approximated.

class networkit.generators.PubWebGenerator(numNodes, numberOfDenseAreas, neighborhoodRadius, maxNumberOfNeighbors)

Bases: networkit.generators.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.

Parameters
  • 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]

getCoordinates()

Returns a list of coordinates

Returns

2D coordinates of all nodes in the graph.

Return type

list(tuple(float,float))

class networkit.generators.RegularRingLatticeGenerator(nNodes, nNeighbors)

Bases: networkit.generators.StaticGraphGenerator

Constructs a regular ring lattice.

Parameters
  • nNodes (int) – Number of nodes in the target graph.

  • nNeighbors (int) – Number of neighbors on each side of a node.

class networkit.generators.RmatGenerator(scale, edgeFactor, a, b, c, d, weighted=False, reduceNodes=0)

Bases: networkit.generators.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.

Parameters
  • 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.

fit(G, scale=1, initiator=None, kronfit=True, iterations=50)

Fit model to input graph

Parameters
  • 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

Returns

A new scaled graph.

Return type

networkit.Graph

setPaths(kronfitPath)

Helper function for fit. Sets an output folder for writing the result to.

Parameters

kronfitPath (str) – String containing a path.

class networkit.generators.StaticGraphGenerator

Bases: object

Abstract base class for static graph generators

generate()

Generates the graph.

Returns

The generated graph.

Return type

networkit.Graph

class networkit.generators.WattsStrogatzGenerator(nNodes, nNeighbors, p)

Bases: networkit.generators.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.

Parameters
  • nNodes (int) – Number of nodes in the target graph.

  • nNeighbors (int) – Number of neighbors on each side of a node.

  • p (float) – Rewiring probability.