Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

Graph Generators

Provides various graph generator functions. More...

Randomized graph generators

void ogdf::randomRegularGraph (Graph &G, int n, int d)
 Creates a random d-regular graph. This method is not guaranteed to terminate! More...
 
void ogdf::randomGraph (Graph &G, int n, int m)
 Creates a random graph. More...
 
bool ogdf::randomSimpleGraph (Graph &G, int n, int m)
 Creates a random simple graph. More...
 
void ogdf::randomBiconnectedGraph (Graph &G, int n, int m)
 Creates a random biconnected graph. More...
 
void ogdf::planarConnectedGraph (Graph &G, int n, int m)
 Creates a random connected (simple) planar (embedded) graph. More...
 
void ogdf::planarBiconnectedGraph (Graph &G, int n, int m, bool multiEdges=false)
 Creates a random planar biconnected (embedded) graph. More...
 
void ogdf::planarBiconnectedDiGraph (Graph &G, int n, int m, double p=0, bool multiEdges=false)
 Creates a random planar biconnected acyclic (embedded) digraph. More...
 
void ogdf::upwardPlanarBiconnectedDiGraph (Graph &G, int n, int m)
 Creates a random upward planar biconnected (embedded) digraph. More...
 
void ogdf::planarCNBGraph (Graph &G, int n, int m, int b)
 Creates a random planar graph, that is connected, but not biconnected. More...
 
void ogdf::randomTriconnectedGraph (Graph &G, int n, double p1, double p2)
 Creates a random triconnected (and simple) graph. More...
 
void ogdf::planarTriconnectedGraph (Graph &G, int n, int m)
 Creates a random planar triconnected (and simple) graph. More...
 
void ogdf::planarTriconnectedGraph (Graph &G, int n, double p1, double p2)
 Creates a random planar triconnected (and simple) graph. More...
 
void ogdf::randomTree (Graph &G, int n)
 Creates a random tree (simpler version. More...
 
void ogdf::randomTree (Graph &G, int n, int maxDeg, int maxWidth)
 Creates a random tree. More...
 
void ogdf::randomHierarchy (Graph &G, int n, int m, bool planar, bool singleSource, bool longEdges)
 Creates a random hierarchical graph. More...
 
void ogdf::randomClusterPlanarGraph (ClusterGraph &C, Graph &G, int cNum)
 Assigns random clusters to a given graph G. More...
 
void ogdf::randomClusterGraph (ClusterGraph &C, Graph &G, int cNum)
 Assigns random clusters to a given graph G. More...
 
void ogdf::randomClusterGraph (ClusterGraph &C, const Graph &G, const node root, int moreInLeaves)
 Assigns a specified cluster structure to a given graph G, and assigns vertices to clusters. More...
 
void ogdf::randomDiGraph (Graph &G, int n, double p)
 Creates a random (simple) directed graph. More...
 
void ogdf::randomSeriesParallelDAG (Graph &G, int edges, double p=0.5, double flt=0.0)
 Creates a random (simple, biconnected) series parallel DAG. More...
 
void ogdf::randomGeometricCubeGraph (Graph &G, int nodes, double threshold, int dimension=2)
 Creates a random geometric graph by laying out nodes in a unit n-cube. Nodes with a distance < threshold are connected, 0 <= threshold <= sqrt(dimension). The graph is simple. More...
 

Deterministic graph generators

void ogdf::customGraph (Graph &G, int n, List< std::pair< int, int >> edges, Array< node > &nodes)
 Creates a custom graph using a list of pairs to determine the graph's edges. More...
 
void ogdf::customGraph (Graph &G, int n, List< std::pair< int, int >> edges)
 Creates a custom graph using a list of pairs to determine the graph's edges. More...
 
void ogdf::circulantGraph (Graph &G, int n, Array< int > jumps)
 Creates a circulant graph. More...
 
void ogdf::regularTree (Graph &G, int n, int children)
 Creates a regular tree. More...
 
void ogdf::completeGraph (Graph &G, int n)
 Creates the complete graph K_n. More...
 
void ogdf::completeKPartiteGraph (Graph &G, const Array< int > &signature)
 Creates the complete k-partite graph K_{k1,k2,...,kn}. More...
 
void ogdf::completeBipartiteGraph (Graph &G, int n, int m)
 Creates the complete bipartite graph K_{n,m}. More...
 
void ogdf::wheelGraph (Graph &G, int n)
 Creates the graph W_n: A wheel graph. More...
 
void ogdf::cubeGraph (Graph &G, int n)
 Creates the graph Q^n: A n-cube graph. More...
 
void ogdf::suspension (Graph &G, int s)
 Modifies G by adding its n-th suspension. More...
 
void ogdf::gridGraph (Graph &G, int n, int m, bool loopN, bool loopM)
 Creates a (toroidal) grid graph on n x m nodes. More...
 
void ogdf::petersenGraph (Graph &G, int n, int m)
 Creates a generalized Petersen graph. More...
 
void ogdf::emptyGraph (Graph &G, int nodes)
 Creates a graph with nodes nodes and no edges. More...
 

Detailed Description

Provides various graph generator functions.

Function Documentation

◆ circulantGraph()

void ogdf::circulantGraph ( Graph &  G,
int  n,
Array< int >  jumps 
)

Creates a circulant graph.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.
jumpsis the array s_1, s_2 ... of distances of adjacent nodes, s.t. each node v is adjacent to (v ± s_i) mod n.

◆ completeBipartiteGraph()

void ogdf::completeBipartiteGraph ( Graph &  G,
int  n,
int  m 
)

Creates the complete bipartite graph K_{n,m}.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the first partition set.
mis the number of nodes of the second partition set.

◆ completeGraph()

void ogdf::completeGraph ( Graph &  G,
int  n 
)

Creates the complete graph K_n.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.

◆ completeKPartiteGraph()

void ogdf::completeKPartiteGraph ( Graph &  G,
const Array< int > &  signature 
)

Creates the complete k-partite graph K_{k1,k2,...,kn}.

Parameters
Gis assigned the generated graph.
signaturecontains the positive values k1, k2, ..., kn.

◆ cubeGraph()

void ogdf::cubeGraph ( Graph &  G,
int  n 
)

Creates the graph Q^n: A n-cube graph.

Parameters
Gis assigned the generated graph.
nis the number of the cube's dimensions (n>=0).

◆ customGraph() [1/2]

void ogdf::customGraph ( Graph &  G,
int  n,
List< std::pair< int, int >>  edges,
Array< node > &  nodes 
)

Creates a custom graph using a list of pairs to determine the graph's edges.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.
edgesis a list of pairs, each one representing two nodes that should be connected by an edge in the generated graph.
nodesresulting array mapping node index to the actual node

◆ customGraph() [2/2]

void ogdf::customGraph ( Graph &  G,
int  n,
List< std::pair< int, int >>  edges 
)
inline

Creates a custom graph using a list of pairs to determine the graph's edges.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.
edgesis a list of pairs, each one representing two nodes that should be connected by an edge in the generated graph.

Definition at line 322 of file graph_generators.h.

◆ emptyGraph()

void ogdf::emptyGraph ( Graph &  G,
int  nodes 
)

Creates a graph with nodes nodes and no edges.

Parameters
Gis assigned the generated graph.
nodesis the number of nodes of the generated graph.

◆ gridGraph()

void ogdf::gridGraph ( Graph &  G,
int  n,
int  m,
bool  loopN,
bool  loopM 
)

Creates a (toroidal) grid graph on n x m nodes.

Parameters
Gis assigned the generated graph.
nis the number of nodes on first axis.
mis the number of nodes on second axis.
loopNif the grid is cyclic on first axis
loopMif the grid is cyclic on second axis

◆ petersenGraph()

void ogdf::petersenGraph ( Graph &  G,
int  n,
int  m 
)

Creates a generalized Petersen graph.

Parameters
Gis assigned the generated graph.
nis the number of nodes on outer cycle.
mis the number of jumps.

◆ planarBiconnectedDiGraph()

void ogdf::planarBiconnectedDiGraph ( Graph &  G,
int  n,
int  m,
double  p = 0,
bool  multiEdges = false 
)

Creates a random planar biconnected acyclic (embedded) digraph.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.
mis the number of edges of the generated graph.
pup to m * p edges will be reversed preversing acyclicity; default = 0.0.
multiEdgesdetermines if the generated graph may contain multi-edges; default = false.

◆ planarBiconnectedGraph()

void ogdf::planarBiconnectedGraph ( Graph &  G,
int  n,
int  m,
bool  multiEdges = false 
)

Creates a random planar biconnected (embedded) graph.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.
mis the number of edges of the generated graph.
multiEdgesdetermines if the generated graph may contain multi-edges.

◆ planarCNBGraph()

void ogdf::planarCNBGraph ( Graph &  G,
int  n,
int  m,
int  b 
)

Creates a random planar graph, that is connected, but not biconnected.

Parameters
Gis assigned the generated graph.
nis the max. number of nodes in each biconencted component
mis the max. number of edges in each biconnected component
bis the number of biconnected components

◆ planarConnectedGraph()

void ogdf::planarConnectedGraph ( Graph &  G,
int  n,
int  m 
)

Creates a random connected (simple) planar (embedded) graph.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.
mis the number of edges of the generated graph.

◆ planarTriconnectedGraph() [1/2]

void ogdf::planarTriconnectedGraph ( Graph &  G,
int  n,
int  m 
)

Creates a random planar triconnected (and simple) graph.

This graph generator works in two steps.

  1. A planar triconnected 3-regular graph is constructed using successive splitting of pairs of nodes. The constructed graph has n nodes and 1.5n edges.
  2. The remaining edges are inserted by successive splitting of faces with degree four or greater. The resulting graph also represents a combinatorial embedding.
Parameters
Gis assigned the generated graph.
nis the number of nodes in the generated graph.
mis the number of edges in the generated graph.
Precondition
  • n >= 4 and n must be even; otherwise, n is adjusted to the next feasible integer.
  • 1.5n <= m <= 3n -6; otherwise, m is adjusted to a feasible value.

◆ planarTriconnectedGraph() [2/2]

void ogdf::planarTriconnectedGraph ( Graph &  G,
int  n,
double  p1,
double  p2 
)

Creates a random planar triconnected (and simple) graph.

This graph generator creates a planar triconnected graph by successive node splitting. It starts with the K_4 and performs n -4 node splits. Each such split operation distributes a node's neighbors to the two nodes resulting from the split. Aftewards, two further edges can be added; the probability for adding these edges is given by p1 and p2. The higher these probabilities, the denser the resulting graph. Note that a simple planar triconnected graph has between 1.5n and 3n -6 edges.

Precondition
0.0 <= p1, p2 <= 1.0.
Parameters
Gis assigned the generated graph.
nis the number of nodes in the generated graph.
p1is the probability for the first additional edge to be added.
p2is the probability for the second additional edge to be added.

◆ randomBiconnectedGraph()

void ogdf::randomBiconnectedGraph ( Graph &  G,
int  n,
int  m 
)

Creates a random biconnected graph.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.
mis the number of edges of the generated graph.

◆ randomClusterGraph() [1/2]

void ogdf::randomClusterGraph ( ClusterGraph &  C,
Graph &  G,
int  cNum 
)

Assigns random clusters to a given graph G.

This function is called with a graph G and creates randomly clusters.

Parameters
Gis the input graph.
Cis a cluster graph for G.
cNumis the maximal number of clusters introduced.
Precondition
G is connected and not empty and C is initialized with G.

◆ randomClusterGraph() [2/2]

void ogdf::randomClusterGraph ( ClusterGraph &  C,
const Graph &  G,
const node  root,
int  moreInLeaves 
)

Assigns a specified cluster structure to a given graph G, and assigns vertices to clusters.

This function is called with a graph G and the root of a second graph, resembling a tree, that gives the cluster structure. Then, the vertices of G are randomly assigned to the clusters, where we can guarantee that any leaf-cluster has (on average) moreInLeaves-times more vertices than a non-leaf cluster. (E.g. if moreInLeaves = 5, any leaf will contain roughly 5 times more vertices than an inner cluster)

Parameters
Cis a cluster graph for G, to be assigned the solution.
Gis the input graph.
rootis a node in some other graph (say T). T is a tree that we will consider rooted at root. T is the pattern for the cluster hierarchy.
moreInLeavesis a factor such that leaf-clusters have on average moreInLeaves-times more vertices than inner clusters
Precondition
G contains at least twice as many nodes as T has leaves.

◆ randomClusterPlanarGraph()

void ogdf::randomClusterPlanarGraph ( ClusterGraph &  C,
Graph &  G,
int  cNum 
)

Assigns random clusters to a given graph G.

This function is called with a graph G and creates randomly clusters. The resulting cluster graph is always c-connected and, if G is planar, also c-planar.

Parameters
Gis the input graph.
Cis a cluster graph for G.
cNumis the maximal number of Clusters introduced.
Precondition
G is connected and not empty and C is initialized with G.

◆ randomDiGraph()

void ogdf::randomDiGraph ( Graph &  G,
int  n,
double  p 
)

Creates a random (simple) directed graph.

Parameters
Gis assigned the generated graph.
nis the number of nodes in the generated graph.
pis the probability that an edge is created (for each node pair)

◆ randomGeometricCubeGraph()

void ogdf::randomGeometricCubeGraph ( Graph &  G,
int  nodes,
double  threshold,
int  dimension = 2 
)

Creates a random geometric graph by laying out nodes in a unit n-cube. Nodes with a distance < threshold are connected, 0 <= threshold <= sqrt(dimension). The graph is simple.

Parameters
Gis assigned the generated graph.
nodesis the number of nodes of the generated graph.
thresholdis threshold radius of nodes which will be connected.
dimensionis the dimension of the cube.

◆ randomGraph()

void ogdf::randomGraph ( Graph &  G,
int  n,
int  m 
)

Creates a random graph.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.
mis the number of edges of the generated graph.

◆ randomHierarchy()

void ogdf::randomHierarchy ( Graph &  G,
int  n,
int  m,
bool  planar,
bool  singleSource,
bool  longEdges 
)

Creates a random hierarchical graph.

Parameters
Gis assigned the generated graph.
nis the number of nodes.
mis the number of edges.
planardetermines if the resulting graph is (level-)planar.
singleSourcedetermines if the graph is a single-source graph.
longEdgesdetermines if the graph has long edges (spanning 2 layers or more); otherwise the graph is proper.

◆ randomRegularGraph()

void ogdf::randomRegularGraph ( Graph &  G,
int  n,
int  d 
)

Creates a random d-regular graph. This method is not guaranteed to terminate!

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.
dis the degree of each vertex

◆ randomSeriesParallelDAG()

void ogdf::randomSeriesParallelDAG ( Graph &  G,
int  edges,
double  p = 0.5,
double  flt = 0.0 
)

Creates a random (simple, biconnected) series parallel DAG.

This function creates a random series parallel biconnected DAG. Note, that the resulting graph is trivially upward planar! To use this generator for experiments, e.g. concerning upward planarity, you can fit the graph by reversing some edges with the parameter 0 < flt < 1.

Parameters
Gis assigned the generated graph.
edgesis the number of edges in the generated graph.
p= probability of a series composition; default = 0.5
flt= up to edges*flt edges will be reversed preversing acyclicity; default = 0.0

◆ randomSimpleGraph()

bool ogdf::randomSimpleGraph ( Graph &  G,
int  n,
int  m 
)

Creates a random simple graph.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.
mis the number of edges of the generated graph.

◆ randomTree() [1/2]

void ogdf::randomTree ( Graph &  G,
int  n 
)

Creates a random tree (simpler version.

Parameters
Gis assigned the tree.
nis the number of nodes of the tree.

◆ randomTree() [2/2]

void ogdf::randomTree ( Graph &  G,
int  n,
int  maxDeg,
int  maxWidth 
)

Creates a random tree.

Parameters
Gis assigned the tree.
nis the number of nodes of the tree.
maxDegis the maximal allowed node degree; 0 means no restriction.
maxWidthis the maximal allowed width of a level; 0 means no restriction.

◆ randomTriconnectedGraph()

void ogdf::randomTriconnectedGraph ( Graph &  G,
int  n,
double  p1,
double  p2 
)

Creates a random triconnected (and simple) graph.

The graph generator proceeds as follows. It starts with a K_4 and performs then n -4 split node operations on randomly selected nodes of the graph constructed so far. Each such operation splits a node v into two nodes x and y and distributes v's neighbors to the two nodes such that each node gets at least two neighbors. Additionally, the edge (x,y) is inserted.

The neighbors are distributed such that a neighbor of v becomes

  • only a neighbor of x with probability p1;
  • only a neighbor of y with probability p1;
  • a neighbor of both x and y with probability 1.0 - p1 - p2.
Parameters
Gis assigned the generated graph.
nis the number of nodes in the generated graph.
p1is the probability that an edge is moved only to the left node after splitting a node.
p2is the probability that an edge is moved only to the right node after splitting a node.

The probability for a neighbor to be moved to both split nodes is 1.0 - p1 - p2. The higher this probability, the higher the density of the resulting graph.

Precondition
The probabilities p1 and p2 must lie between 0.0 and 1.0, and p1 + p2 <= 1.0.

◆ regularTree()

void ogdf::regularTree ( Graph &  G,
int  n,
int  children 
)

Creates a regular tree.

Parameters
Gis assigned the tree.
nis the number of nodes of the tree.
childrenis the number of children per node. root has index 0, the next level has indizes 1...children, the children of node 1 have indizes children+1...2*children, etc. if number of nodes does not allow a regular node, the "last" node will have fewer children.

◆ suspension()

void ogdf::suspension ( Graph &  G,
int  s 
)

Modifies G by adding its n-th suspension.

Parameters
Gis the graph to extend.
sis the suspension.

◆ upwardPlanarBiconnectedDiGraph()

void ogdf::upwardPlanarBiconnectedDiGraph ( Graph &  G,
int  n,
int  m 
)

Creates a random upward planar biconnected (embedded) digraph.

Parameters
Gis assigned the generated graph.
nis the number of nodes of the generated graph.
mis the number of edges of the generated graph.

◆ wheelGraph()

void ogdf::wheelGraph ( Graph &  G,
int  n 
)

Creates the graph W_n: A wheel graph.

Parameters
Gis assigned the generated graph.
nis the number of nodes on the rim of the wheel (W_n).