Expand description
petgraph-gen
is a crate that extends petgraph
with functions that generate graphs with different properties.
Functions§
- barabasi_
albert_ graph - Generates a random graph with
n
nodes using the Barabási-Albert model. The process starts with a star graph ofm + 1
nodes or an initial graph given by theinitial_graph
parameter. Then additional nodes are added one by one. Each new node is connected tom
existing nodes, where the probability of a node being connected to a given node is proportional to the number of edges that node already has. - complete_
graph - Generates a complete graph with
n
nodes. A complete graph is a graph where each node is connected to every other node. On a directed graph, this means that each node hasn - 1
incoming edges andn - 1
outgoing edges. - empty_
graph - Generates an empty graph with
n
nodes and no edges. - random_
gnm_ graph - Generates a random graph according to the
G(n,m)
Erdős-Rényi model. The resulting graph hasn
nodes andm
edges are selected randomly and uniformly from the set of all possible edges (excluding loop edges). - random_
gnp_ graph - Generates a random graph according to the
G(n,p)
Erdős-Rényi model. The resulting graph hasn
nodes and edges are selected with probabilityp
from the set of all possible edges (excluding loop edges). - star_
graph - Generates a star graph with a single center node connected to
n
other nodes. The resulting graph hasn + 1
nodes andn
edges.