Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
graph_generator.c File Reference
#include "config.h"
#include <cgraph/list.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <graph_generator.h>
#include <util/alloc.h>
#include <util/exit.h>
Include dependency graph for graph_generator.c:

Go to the source code of this file.

Data Structures

struct  vtx_data
 
struct  pair
 
struct  tree_t
 
struct  treegen_s
 

Macros

#define OUTE(h)   if (tl < (hd=(h))) ef( tl, hd)
 

Functions

void makePath (unsigned n, edgefn ef)
 
void makeComplete (unsigned n, edgefn ef)
 
void makeCircle (unsigned n, edgefn ef)
 
void makeStar (unsigned n, edgefn ef)
 
void makeWheel (unsigned n, edgefn ef)
 
void makeCompleteB (unsigned dim1, unsigned dim2, edgefn ef)
 
void makeTorus (unsigned dim1, unsigned dim2, edgefn ef)
 
void makeTwistedTorus (unsigned dim1, unsigned dim2, unsigned t1, unsigned t2, edgefn ef)
 
void makeCylinder (unsigned dim1, unsigned dim2, edgefn ef)
 
void makeSquareGrid (unsigned dim1, unsigned dim2, int connect_corners, int partial, edgefn ef)
 
void makeTree (unsigned depth, unsigned nary, edgefn ef)
 
void makeBinaryTree (unsigned depth, edgefn ef)
 
static void constructSierpinski (unsigned v1, unsigned v2, unsigned v3, unsigned depth, vtx_data *graph)
 
void makeSierpinski (unsigned depth, edgefn ef)
 
static void constructTetrix (unsigned v1, unsigned v2, unsigned v3, unsigned v4, unsigned depth, vtx_data *graph)
 
void makeTetrix (unsigned depth, edgefn ef)
 
void makeHypercube (unsigned dim, edgefn ef)
 
void makeTriMesh (unsigned sz, edgefn ef)
 
void makeBall (unsigned w, unsigned h, edgefn ef)
 
void makeRandom (unsigned h, unsigned w, edgefn ef)
 
void makeMobius (unsigned w, unsigned h, edgefn ef)
 
static tree_tmkTree (unsigned sz)
 
static void freeTree (tree_t *tp)
 
static void resetTree (tree_t *tp)
 
static unsigned treeRoot (tree_t *tp)
 
static unsigned prevRoot (tree_t *tp)
 
static unsigned treeSize (tree_t *tp)
 
static unsigned treeTop (tree_t *tp)
 
static void treePop (tree_t *tp)
 
static void addTree (tree_t *tp, unsigned sz)
 
static void treeDup (tree_t *tp, unsigned J)
 
static void push (int_stack_t *sp, unsigned j, unsigned d)
 
static pair pop (int_stack_t *sp)
 
static unsigned * genCnt (unsigned NN)
 
static double drand (void)
 
static void genTree (unsigned NN, unsigned *T, int_stack_t *stack, tree_t *TREE)
 
static void writeTree (tree_t *tp, edgefn ef)
 
treegen_tmakeTreeGen (unsigned N)
 
void makeRandomTree (treegen_t *tg, edgefn ef)
 
void freeTreeGen (treegen_t *tg)
 

Macro Definition Documentation

◆ OUTE

#define OUTE (   h)    if (tl < (hd=(h))) ef( tl, hd)

Definition at line 137 of file graph_generator.c.

Function Documentation

◆ addTree()

static void addTree ( tree_t tp,
unsigned  sz 
)
static

Definition at line 498 of file graph_generator.c.

References tree_t::p, tree_t::root, and tree_t::top.

Referenced by genTree().

Here is the caller graph for this function:

◆ constructSierpinski()

static void constructSierpinski ( unsigned  v1,
unsigned  v2,
unsigned  v3,
unsigned  depth,
vtx_data graph 
)
static

Definition at line 203 of file graph_generator.c.

References constructSierpinski(), graph(), and nedges.

Referenced by constructSierpinski(), and makeSierpinski().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ constructTetrix()

static void constructTetrix ( unsigned  v1,
unsigned  v2,
unsigned  v3,
unsigned  v4,
unsigned  depth,
vtx_data graph 
)
static

Definition at line 263 of file graph_generator.c.

References constructTetrix(), graph(), and nedges.

Referenced by constructTetrix(), and makeTetrix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drand()

static double drand ( void  )
static

◆ freeTree()

static void freeTree ( tree_t tp)
static

Definition at line 463 of file graph_generator.c.

References free(), and tree_t::p.

Referenced by freeTreeGen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freeTreeGen()

void freeTreeGen ( treegen_t tg)

Definition at line 654 of file graph_generator.c.

References free(), freeTree(), treegen_s::sp, treegen_s::T, and treegen_s::tp.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ genCnt()

static unsigned * genCnt ( unsigned  NN)
static

Definition at line 537 of file graph_generator.c.

References D, gv_calloc(), I, and T.

Referenced by makeTreeGen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ genTree()

static void genTree ( unsigned  NN,
unsigned *  T,
int_stack_t *  stack,
tree_t TREE 
)
static

Definition at line 567 of file graph_generator.c.

References addTree(), pair::d, D, drand(), pair::j, M, N, pop(), push(), T, treeDup(), treePop(), and treeTop().

Referenced by makeRandomTree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeBall()

void makeBall ( unsigned  w,
unsigned  h,
edgefn  ef 
)

Definition at line 370 of file graph_generator.c.

References makeCylinder().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeBinaryTree()

void makeBinaryTree ( unsigned  depth,
edgefn  ef 
)

Definition at line 189 of file graph_generator.c.

Referenced by main(), and makeRandom().

Here is the caller graph for this function:

◆ makeCircle()

void makeCircle ( unsigned  n,
edgefn  ef 
)

Definition at line 44 of file graph_generator.c.

References makePath().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeComplete()

void makeComplete ( unsigned  n,
edgefn  ef 
)

Definition at line 32 of file graph_generator.c.

Referenced by main(), and makeWheel().

Here is the caller graph for this function:

◆ makeCompleteB()

void makeCompleteB ( unsigned  dim1,
unsigned  dim2,
edgefn  ef 
)

Definition at line 81 of file graph_generator.c.

Referenced by main().

Here is the caller graph for this function:

◆ makeCylinder()

void makeCylinder ( unsigned  dim1,
unsigned  dim2,
edgefn  ef 
)

Definition at line 121 of file graph_generator.c.

Referenced by main(), and makeBall().

Here is the caller graph for this function:

◆ makeHypercube()

void makeHypercube ( unsigned  dim,
edgefn  ef 
)

Definition at line 335 of file graph_generator.c.

References dim, and neighbor.

Referenced by main().

Here is the caller graph for this function:

◆ makeMobius()

void makeMobius ( unsigned  w,
unsigned  h,
edgefn  ef 
)

Definition at line 415 of file graph_generator.c.

References makePath().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makePath()

void makePath ( unsigned  n,
edgefn  ef 
)

Definition at line 23 of file graph_generator.c.

Referenced by main(), makeCircle(), makeMobius(), makeRandom(), makeStar(), and Pobspath().

Here is the caller graph for this function:

◆ makeRandom()

void makeRandom ( unsigned  h,
unsigned  w,
edgefn  ef 
)

Definition at line 385 of file graph_generator.c.

References makeBinaryTree(), makePath(), and type.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeRandomTree()

void makeRandomTree ( treegen_t tg,
edgefn  ef 
)

Definition at line 645 of file graph_generator.c.

References genTree(), treegen_s::N, resetTree(), treegen_s::sp, treegen_s::T, treegen_s::tp, and writeTree().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeSierpinski()

void makeSierpinski ( unsigned  depth,
edgefn  ef 
)

Definition at line 234 of file graph_generator.c.

References constructSierpinski(), free(), graph(), and gv_calloc().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeSquareGrid()

void makeSquareGrid ( unsigned  dim1,
unsigned  dim2,
int  connect_corners,
int  partial,
edgefn  ef 
)

Definition at line 139 of file graph_generator.c.

References OUTE.

Referenced by main().

Here is the caller graph for this function:

◆ makeStar()

void makeStar ( unsigned  n,
edgefn  ef 
)

Definition at line 56 of file graph_generator.c.

References makePath().

Referenced by main(), and makeWheel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeTetrix()

void makeTetrix ( unsigned  depth,
edgefn  ef 
)

Definition at line 306 of file graph_generator.c.

References constructTetrix(), free(), graph(), and gv_calloc().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeTorus()

void makeTorus ( unsigned  dim1,
unsigned  dim2,
edgefn  ef 
)

Definition at line 89 of file graph_generator.c.

Referenced by main().

Here is the caller graph for this function:

◆ makeTree()

void makeTree ( unsigned  depth,
unsigned  nary,
edgefn  ef 
)

Definition at line 178 of file graph_generator.c.

Referenced by main().

Here is the caller graph for this function:

◆ makeTreeGen()

treegen_t * makeTreeGen ( unsigned  N)

Definition at line 633 of file graph_generator.c.

References genCnt(), gv_alloc(), mkTree(), N, treegen_s::N, treegen_s::sp, treegen_s::T, and treegen_s::tp.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeTriMesh()

void makeTriMesh ( unsigned  sz,
edgefn  ef 
)

Definition at line 347 of file graph_generator.c.

Referenced by main().

Here is the caller graph for this function:

◆ makeTwistedTorus()

void makeTwistedTorus ( unsigned  dim1,
unsigned  dim2,
unsigned  t1,
unsigned  t2,
edgefn  ef 
)

Definition at line 106 of file graph_generator.c.

Referenced by main().

Here is the caller graph for this function:

◆ makeWheel()

void makeWheel ( unsigned  n,
edgefn  ef 
)

Definition at line 67 of file graph_generator.c.

References makeComplete(), and makeStar().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mkTree()

static tree_t * mkTree ( unsigned  sz)
static

Definition at line 454 of file graph_generator.c.

References gv_alloc(), gv_calloc(), tree_t::p, tree_t::root, and tree_t::top.

Referenced by makeTreeGen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pop()

static pair pop ( int_stack_t *  sp)
static

Definition at line 526 of file graph_generator.c.

◆ prevRoot()

static unsigned prevRoot ( tree_t tp)
static

Definition at line 480 of file graph_generator.c.

References tree_t::p, and tree_t::root.

Referenced by treeDup(), and treePop().

Here is the caller graph for this function:

◆ push()

static void push ( int_stack_t *  sp,
unsigned  j,
unsigned  d 
)
static

Definition at line 521 of file graph_generator.c.

Referenced by genTree().

Here is the caller graph for this function:

◆ resetTree()

static void resetTree ( tree_t tp)
static

Definition at line 470 of file graph_generator.c.

References tree_t::root, and tree_t::top.

Referenced by makeRandomTree().

Here is the caller graph for this function:

◆ treeDup()

static void treeDup ( tree_t tp,
unsigned  J 
)
static

Definition at line 505 of file graph_generator.c.

References L, M, tree_t::p, prevRoot(), tree_t::top, treeRoot(), and treeSize().

Referenced by genTree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ treePop()

static void treePop ( tree_t tp)
static

Definition at line 493 of file graph_generator.c.

References prevRoot(), and tree_t::root.

Referenced by genTree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ treeRoot()

static unsigned treeRoot ( tree_t tp)
static

Definition at line 476 of file graph_generator.c.

References tree_t::root.

Referenced by treeDup().

Here is the caller graph for this function:

◆ treeSize()

static unsigned treeSize ( tree_t tp)
static

Definition at line 484 of file graph_generator.c.

References tree_t::root, and tree_t::top.

Referenced by treeDup().

Here is the caller graph for this function:

◆ treeTop()

static unsigned treeTop ( tree_t tp)
static

Definition at line 488 of file graph_generator.c.

References tree_t::top.

Referenced by genTree().

Here is the caller graph for this function:

◆ writeTree()

static void writeTree ( tree_t tp,
edgefn  ef 
)
static

Definition at line 620 of file graph_generator.c.

References tree_t::p, and tree_t::top.

Referenced by makeRandomTree().

Here is the caller graph for this function: