networkx.generators

A package for generating various graphs in networkx.

Functions

LCF_graph(n, shift_list, repeats[, create_using]) Return the cubic graph specified in LCF notation.
balanced_tree(r, h[, create_using]) Return the perfectly balanced r-ary tree of height h.
barabasi_albert_graph(n, m[, seed]) Returns a random graph according to the Barabási–Albert preferential attachment model.
barbell_graph(m1, m2[, create_using]) Return the Barbell Graph: two complete graphs connected by a path.
binomial_graph(n, p[, seed, directed]) Returns a G_{n,p} random graph, also known as an Erdős-Rényi graph or a binomial graph.
bull_graph([create_using]) Return the Bull graph.
caveman_graph(l, k) Returns a caveman graph of l cliques of size k.
chordal_cycle_graph(p[, create_using]) Return the chordal cycle graph on p nodes.
chvatal_graph([create_using]) Return the Chvátal graph.
circulant_graph(n, offsets[, create_using]) Generates the circulant graph Ci_n(x_1, x_2, ..., x_m) with n vertices.
circular_ladder_graph(n[, create_using]) Return the circular ladder graph CL_n of length n.
complete_graph(n[, create_using]) Return the complete graph K_n with n nodes.
complete_multipartite_graph(*block_sizes) Returns the complete multipartite graph with the specified block sizes.
configuration_model(deg_sequence[, ...]) Return a random graph with the given degree sequence.
connected_caveman_graph(l, k) Returns a connected caveman graph of l cliques of size k.
connected_watts_strogatz_graph(n, k, p[, ...]) Returns a connected Watts–Strogatz small-world graph.
cubical_graph([create_using]) Return the 3-regular Platonic Cubical graph.
cycle_graph(n[, create_using]) Return the cycle graph C_n of cyclicly connected nodes.
davis_southern_women_graph() Return Davis Southern women social network.
degree_sequence_tree(deg_sequence[, ...]) Make a tree for the given degree sequence.
dense_gnm_random_graph(n, m[, seed]) Returns a G_{n,m} random graph.
desargues_graph([create_using]) Return the Desargues graph.
diamond_graph([create_using]) Return the Diamond graph.
directed_configuration_model(...[, ...]) Return a directed_random graph with the given degree sequences.
directed_havel_hakimi_graph(in_deg_sequence, ...) Return a directed graph with the given degree sequences.
dodecahedral_graph([create_using]) Return the Platonic Dodecahedral graph.
dorogovtsev_goltsev_mendes_graph(n[, ...]) Return the hierarchically constructed Dorogovtsev-Goltsev-Mendes graph.
duplication_divergence_graph(n, p[, seed]) Returns an undirected graph using the duplication-divergence model.
ego_graph(G, n[, radius, center, ...]) Returns induced subgraph of neighbors centered at node n within a given radius.
empty_graph([n, create_using]) Return the empty graph with n nodes and zero edges.
erdos_renyi_graph(n, p[, seed, directed]) Returns a G_{n,p} random graph, also known as an Erdős-Rényi graph or a binomial graph.
expected_degree_graph(w[, seed, selfloops]) Return a random graph with given expected degrees.
fast_gnp_random_graph(n, p[, seed, directed]) Returns a G_{n,p} random graph, also known as an Erdős-Rényi graph or a binomial graph.
florentine_families_graph() Return Florentine families graph.
frucht_graph([create_using]) Return the Frucht Graph.
full_rary_tree(r, n[, create_using]) Creates a full r-ary tree of n vertices.
gaussian_random_partition_graph(n, s, v, ...) Generate a Gaussian random partition graph.
general_random_intersection_graph(n, m, p) Return a random intersection graph with independent probabilities for connections between node and attribute sets.
geographical_threshold_graph(n, theta[, ...]) Returns a geographical threshold graph.
gn_graph(n[, kernel, create_using, seed]) Return the growing network (GN) digraph with n nodes.
gnc_graph(n[, create_using, seed]) Return the growing network with copying (GNC) digraph with n nodes.
gnm_random_graph(n, m[, seed, directed]) Returns a G_{n,m} random graph.
gnp_random_graph(n, p[, seed, directed]) Returns a G_{n,p} random graph, also known as an Erdős-Rényi graph or a binomial graph.
gnr_graph(n, p[, create_using, seed]) Return the growing network with redirection (GNR) digraph with n nodes and redirection probability p.
grid_2d_graph(m, n[, periodic, create_using]) Return the 2d grid graph of mxn nodes
grid_graph(dim[, periodic]) Return the n-dimensional grid graph.
havel_hakimi_graph(deg_sequence[, create_using]) Return a simple graph with given degree sequence constructed using the Havel-Hakimi algorithm.
heawood_graph([create_using]) Return the Heawood graph, a (3,6) cage.
house_graph([create_using]) Return the House graph (square with triangle on top).
house_x_graph([create_using]) Return the House graph with a cross inside the house square.
hypercube_graph(n) Return the n-dimensional hypercube.
icosahedral_graph([create_using]) Return the Platonic Icosahedral graph.
is_valid_joint_degree(joint_degrees) Checks whether the given joint degree dictionary is realizable as a simple graph.
joint_degree_graph(joint_degrees[, seed]) Generates a random simple graph with the given joint degree dictionary.
k_random_intersection_graph(n, m, k) Return a intersection graph with randomly chosen attribute sets for each node that are of equal size (k).
karate_club_graph() Return Zachary’s Karate Club graph.
krackhardt_kite_graph([create_using]) Return the Krackhardt Kite Social Network.
ladder_graph(n[, create_using]) Return the Ladder graph of length n.
line_graph(G[, create_using]) Returns the line graph of the graph or digraph G.
lollipop_graph(m, n[, create_using]) Return the Lollipop Graph; K_m connected to P_n.
make_small_graph(graph_description[, ...]) Return the small graph described by graph_description.
margulis_gabber_galil_graph(n[, create_using]) Return the Margulis-Gabber-Galil undirected MultiGraph on n^2 nodes.
moebius_kantor_graph([create_using]) Return the Moebius-Kantor graph.
navigable_small_world_graph(n[, p, q, r, ...]) Return a navigable small-world graph.
newman_watts_strogatz_graph(n, k, p[, seed]) Return a Newman–Watts–Strogatz small-world graph.
nonisomorphic_trees(order[, create]) Returns a list of nonisomporphic trees
null_graph([create_using]) Return the Null graph with no nodes or edges.
number_of_nonisomorphic_trees(order) Returns the number of nonisomorphic trees
octahedral_graph([create_using]) Return the Platonic Octahedral graph.
pappus_graph() Return the Pappus graph.
partial_duplication_graph(N, n, p, q[, seed]) Return a random graph using the partial duplication model.
path_graph(n[, create_using]) Return the Path graph P_n of linearly connected nodes.
petersen_graph([create_using]) Return the Petersen graph.
planted_partition_graph(l, k, p_in, p_out[, ...]) Return the planted l-partition graph.
powerlaw_cluster_graph(n, m, p[, seed]) Holme and Kim algorithm for growing graphs with powerlaw degree distribution and approximate average clustering.
random_clustered_graph(joint_degree_sequence) Generate a random graph with the given joint independent edge degree and triangle degree sequence.
random_degree_sequence_graph(sequence[, ...]) Return a simple random graph with the given degree sequence.
random_geometric_graph(n, radius[, dim, ...]) Returns a random geometric graph in the unit cube.
random_k_out_graph(n, k, alpha[, ...]) Returns a random k-out graph with preferential attachment.
random_kernel_graph(n, kernel_integral[, ...]) Return an random graph based on the specified kernel.
random_lobster(n, p1, p2[, seed]) Returns a random lobster graph.
random_partition_graph(sizes, p_in, p_out[, ...]) Return the random partition graph with a partition of sizes.
random_powerlaw_tree(n[, gamma, seed, tries]) Returns a tree with a power law degree distribution.
random_powerlaw_tree_sequence(n[, gamma, ...]) Returns a degree sequence for a tree with a power law distribution.
random_regular_graph(d, n[, seed]) Returns a random d-regular graph on n nodes.
random_shell_graph(constructor[, seed]) Returns a random shell graph for the constructor given.
relaxed_caveman_graph(l, k, p[, seed]) Return a relaxed caveman graph.
ring_of_cliques(num_cliques, clique_size) Defines a “ring of cliques” graph.
scale_free_graph(n[, alpha, beta, gamma, ...]) Returns a scale-free directed graph.
sedgewick_maze_graph([create_using]) Return a small maze with a cycle.
star_graph(n[, create_using]) Return the star graph
stochastic_graph(G[, copy, weight]) Returns a right-stochastic representation of directed graph G.
tetrahedral_graph([create_using]) Return the 3-regular Platonic Tetrahedral graph.
triad_graph(triad_name) Returns the triad graph with the given name.
trivial_graph([create_using]) Return the Trivial graph with one node (with label 0) and no edges.
truncated_cube_graph([create_using]) Return the skeleton of the truncated cube.
truncated_tetrahedron_graph([create_using]) Return the skeleton of the truncated Platonic tetrahedron.
tutte_graph([create_using]) Return the Tutte graph.
uniform_random_intersection_graph(n, m, p[, ...]) Return a uniform random intersection graph.
watts_strogatz_graph(n, k, p[, seed]) Return a Watts–Strogatz small-world graph.
waxman_graph(n[, alpha, beta, L, domain, metric]) Return a Waxman random graph.
wheel_graph(n[, create_using]) Return the wheel graph