Crossings Minimization  1.0
ord.h
Go to the documentation of this file.
1 /**
2  * @file ord.h
3  * @brief header for utility functions that read and write .ord files (node
4  * ordering on layers of a graph)
5  * @author Matt Stallmann
6  * @date 29 Dec 1998
7  * $Id: ord.h 2 2011-06-07 19:50:41Z mfms $
8  */
9 
10 // Copyright (C) 2001 Matthias Stallmann.
11 // Contact: matt_stallmann@ncsu.edu
12 //
13 // This program is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation; either version 2 of the License, or
16 // (at your option) any later version.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License along
24 // with this program (file COPYING.txt); if not, write to the Free Software
25 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
26 // USA.
27 
28 // 20 May 2002 - added get_graph_name()
29 // 09 Sep 2008 - modified as a C implementation
30 
31 // Standard format for an ord file is (comments begin with # and end with
32 // newline):
33 //
34 // # Ordering for graph graph_name
35 // # method of generation ('natural' order, treatment, or random seed)
36 //
37 // 0 {
38 // node_0_0 node_0_1 ... node_0_m
39 // }
40 // ...
41 // k {
42 // node_k_0 ... node_k_n
43 // }
44 //
45 // where there are k+1 layers numbered 0 through k
46 //
47 // To read a .ord file via the stream 'in', do the following:
48 // int layer;
49 // char name_buf[MAX_NAME_LENGTH];
50 // while ( nextLayer( in, & layer ) )
51 // {
52 // // initialize the layer
53 // while ( nextNode( in, name_buf ) )
54 // {
55 // // do something with the node whose name is on name_buf
56 // }
57 // }
58 
59 #ifndef ORD_H
60 #define ORD_H
61 
62 #include<stdio.h>
63 #include<stdbool.h>
64 #include"defs.h"
65 
66 bool getGraphName( FILE * in, char * buffer );
67 // PRE: 'in' is a valid istream for a .ord file
68 // 'buffer' is large enough to hold a graph name
69 // POST: 'in' is beyond the initial comments and white space
70 // 'buffer' contains the name of the graph, if any (last word of the
71 // first comment line in the stream)
72 // retval == true iff there was a nonblank comment before there was
73 // any meaningful input
74 
75 bool nextLayer( FILE * in, int * layer );
76 // PRE: 'in' is a valid istream for a .ord file
77 // POST: 'in' is at the first node of the next layer (if any)
78 // 'layer' == the number of the next layer (if any)
79 // retval == true iff there is another layer
80 
81 bool nextNode( FILE * in, char * node_buffer );
82 // PRE: 'in' is a valid istream for a .ord file and is positioned somewhere
83 // inside the list of nodes for a layer
84 // POST: 'in' is beyond the next node (if any)
85 // node_buffer has the string representing the next node in it
86 // retval == true iff there is another node on the current layer
87 
88 // output functions
89 
90 void ordPreamble( FILE * out, const char * graph_name,
91  const char * generation_method );
92 // PRE: 'out' is a valid ostream
93 // POST: comments identifying the graph and the way it was generated have
94 // been written on 'out'
95 
96 /**
97  * Writes text needed for the beginning of a layer
98  * @param out output stream
99  * @param layer layer number
100  * @param type additional information, e.g., whether the ordering was
101  * randomized, natural (based on dot file), or on a heuristic
102  */
103 void beginLayer( FILE * out, int layer, const char * type );
104 
105 void endLayer( FILE * out );
106 // PRE: 'out' is a valid ostream
107 // POST: the encoding for the end of the current layer has been written on
108 // 'out'
109 
110 void outputNode( FILE * out, const char * node );
111 // PRE: 'out' is a valid ostream
112 // POST: the 'node' is listed next for the current layer on 'out'
113 
114 #endif
115 
116 /* [Last modified: 2008 12 29 at 19:01:52 GMT] */
void outputNode(FILE *out, const char *node)
Definition: ord.c:204
bool getGraphName(FILE *in, char *buffer)
Definition: ord.c:97
static char buffer[MAX_NAME_LENGTH]
Definition: heuristics.c:59
Definitions common to all edge crossing heuristic source files.
bool nextNode(FILE *in, char *node_buffer)
Definition: ord.c:146
void ordPreamble(FILE *out, const char *graph_name, const char *generation_method)
Definition: ord.c:180
static char graph_name[MAX_NAME_LENGTH]
Definition: dot.c:42
void beginLayer(FILE *out, int layer, const char *type)
Definition: ord.c:187
bool nextLayer(FILE *in, int *layer)
Definition: ord.c:112
void endLayer(FILE *out)
Definition: ord.c:196