Crossings Minimization  1.0
ord.c File Reference

implementation of utility functions that read and write .ord files (node ordering on layers of a graph) More...

#include "defs.h"
#include "ord.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
Include dependency graph for ord.c:

Go to the source code of this file.

Enumerations

enum  { OUTSIDE_LAYER, LAYER_NUMBER, INSIDE_LAYER }
 

Functions

static bool eatSpaceAndComments (FILE *in)
 
bool getGraphName (FILE *in, char *buffer)
 
bool nextLayer (FILE *in, int *layer)
 
bool nextNode (FILE *in, char *node_buffer)
 
void ordPreamble (FILE *out, const char *graph_name, const char *generation_method)
 
void beginLayer (FILE *out, int layer, const char *type)
 
void endLayer (FILE *out)
 
void outputNode (FILE *out, const char *node)
 

Variables

const char * ORD_SUFFIX = ".ord"
 
const char NULL_CHAR = '\0'
 
const char BLANK_CHAR = ' '
 
const char COMMENT_CHAR = '#'
 
const char END_OF_LINE = '\n'
 
const char OPEN_LIST = '{'
 
const char CLOSE_LIST = '}'
 
static char name_buffer [MAX_NAME_LENGTH]
 
static bool valid_name = false
 
static enum { ... }  state = OUTSIDE_LAYER
 
static int hold_layer = -1
 
static int current_column = 0
 
static int number_of_nodes = 0
 
static int output_layer = -1
 

Detailed Description

implementation of utility functions that read and write .ord files (node ordering on layers of a graph)

Author
Matt Stallmann
Date
1 Jan 1999
Id
ord.c 97 2014-09-10 17:05:19Z mfms

Definition in file ord.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
OUTSIDE_LAYER 
LAYER_NUMBER 
INSIDE_LAYER 

Definition at line 106 of file ord.c.

Function Documentation

◆ beginLayer()

void beginLayer ( FILE *  out,
int  layer,
const char *  type 
)

Writes text needed for the beginning of a layer

Parameters
outoutput stream
layerlayer number
typeadditional information, e.g., whether the ordering was randomized, natural (based on dot file), or on a heuristic

Definition at line 187 of file ord.c.

References current_column, number_of_nodes, and output_layer.

Referenced by writeOrd().

◆ eatSpaceAndComments()

static bool eatSpaceAndComments ( FILE *  in)
static

Definition at line 52 of file ord.c.

References BLANK_CHAR, COMMENT_CHAR, END_OF_LINE, name_buffer, NULL_CHAR, and valid_name.

Referenced by getGraphName(), nextLayer(), and nextNode().

◆ endLayer()

void endLayer ( FILE *  out)

Definition at line 196 of file ord.c.

References number_of_nodes, and output_layer.

Referenced by writeOrd().

◆ getGraphName()

bool getGraphName ( FILE *  in,
char *  buffer 
)

Definition at line 97 of file ord.c.

References eatSpaceAndComments(), name_buffer, and valid_name.

Here is the call graph for this function:

◆ nextLayer()

bool nextLayer ( FILE *  in,
int *  layer 
)

Definition at line 112 of file ord.c.

References CLOSE_LIST, eatSpaceAndComments(), hold_layer, INSIDE_LAYER, LAYER_NUMBER, OPEN_LIST, OUTSIDE_LAYER, and state.

Referenced by allocateLayers(), and assignNodesToLayers().

Here is the call graph for this function:

◆ nextNode()

bool nextNode ( FILE *  in,
char *  node_buffer 
)

Definition at line 146 of file ord.c.

References CLOSE_LIST, COMMENT_CHAR, eatSpaceAndComments(), hold_layer, INSIDE_LAYER, and state.

Referenced by allocateLayers(), and assignNodesToLayers().

Here is the call graph for this function:

◆ ordPreamble()

void ordPreamble ( FILE *  out,
const char *  graph_name,
const char *  generation_method 
)

Definition at line 180 of file ord.c.

Referenced by writeOrd().

◆ outputNode()

void outputNode ( FILE *  out,
const char *  node 
)

Definition at line 204 of file ord.c.

References current_column, LINE_LENGTH, number_of_nodes, and output_layer.

Referenced by writeNodes().

Variable Documentation

◆ BLANK_CHAR

const char BLANK_CHAR = ' '

Definition at line 43 of file ord.c.

Referenced by eatSpaceAndComments().

◆ CLOSE_LIST

const char CLOSE_LIST = '}'

Definition at line 47 of file ord.c.

Referenced by nextLayer(), and nextNode().

◆ COMMENT_CHAR

const char COMMENT_CHAR = '#'

Definition at line 44 of file ord.c.

Referenced by eatSpaceAndComments(), and nextNode().

◆ current_column

int current_column = 0
static

Definition at line 176 of file ord.c.

Referenced by beginLayer(), and outputNode().

◆ END_OF_LINE

const char END_OF_LINE = '\n'

Definition at line 45 of file ord.c.

Referenced by eatSpaceAndComments().

◆ hold_layer

int hold_layer = -1
static

Definition at line 110 of file ord.c.

Referenced by nextLayer(), and nextNode().

◆ name_buffer

char name_buffer[MAX_NAME_LENGTH]
static

Definition at line 49 of file ord.c.

Referenced by create_node(), eatSpaceAndComments(), and getGraphName().

◆ NULL_CHAR

const char NULL_CHAR = '\0'

Definition at line 42 of file ord.c.

Referenced by eatSpaceAndComments().

◆ number_of_nodes

int number_of_nodes = 0
static

Definition at line 177 of file ord.c.

Referenced by beginLayer(), endLayer(), and outputNode().

◆ OPEN_LIST

const char OPEN_LIST = '{'

Definition at line 46 of file ord.c.

Referenced by nextLayer().

◆ ORD_SUFFIX

const char* ORD_SUFFIX = ".ord"

Definition at line 38 of file ord.c.

◆ output_layer

int output_layer = -1
static

Definition at line 178 of file ord.c.

Referenced by beginLayer(), endLayer(), and outputNode().

◆ state

enum { ... } state

◆ valid_name

bool valid_name = false
static

Definition at line 50 of file ord.c.

Referenced by eatSpaceAndComments(), and getGraphName().