]>
git.saurik.com Git - bison.git/blob - src/vcg.c
acaffc043be725c4e77a0a19c97b04ebec591ce5
   1 /* VCG description handler for Bison. 
   2    Copyright 2001 Free Software Foundation, Inc. 
   4    This file is part of Bison, the GNU Compiler Compiler. 
   6    Bison is free software; you can redistribute it and/or modify 
   7    it under the terms of the GNU General Public License as published by 
   8    the Free Software Foundation; either version 2, or (at your option) 
  11    Bison is distributed in the hope that it will be useful, 
  12    but WITHOUT ANY WARRANTY; without even the implied warranty of 
  13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  14    GNU General Public License for more details. 
  16    You should have received a copy of the GNU General Public License 
  17    along with Bison; see the file COPYING.  If not, write to 
  18    the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
  19    Boston, MA 02111-1307, USA.  */ 
  23 #include "vcg_defaults.h" 
  26 /* Initialize a graph with the default values. */ 
  28 new_graph (graph_t 
*g
) 
  33   g
->infos
[0] = G_INFOS1
; 
  34   g
->infos
[1] = G_INFOS2
; 
  35   g
->infos
[2] = G_INFOS3
; 
  38   g
->textcolor 
= G_TEXTCOLOR
; 
  39   g
->bordercolor 
= G_BORDERCOLOR
; 
  43   g
->borderwidth 
= G_BORDERWIDTH
; 
  46   g
->folding 
= G_FOLDING
; 
  48   g
->stretch 
= G_STRETCH
; 
  50   g
->textmode 
= G_TEXTMODE
; 
  53   g
->xmax 
= G_XMAX
; /* Not output. */ 
  54   g
->ymax 
= G_YMAX
; /* Not output. */ 
  61   g
->xlspace 
= G_XLSPACE
; /* Not output. */ 
  63   g
->xraster 
= G_XRASTER
; 
  64   g
->yraster 
= G_YRASTER
; 
  65   g
->xlraster 
= G_XLRASTER
; 
  67   g
->hidden 
= G_HIDDEN
; /* No default value. */ 
  69   g
->classname 
= G_CLASSNAME
; /* No class name association. */ 
  71   g
->layoutalgorithm 
= G_LAYOUTALGORITHM
; 
  72   g
->layout_downfactor 
= G_LAYOUT_DOWNFACTOR
; 
  73   g
->layout_upfactor 
= G_LAYOUT_UPFACTOR
; 
  74   g
->layout_nearfactor 
= G_LAYOUT_NEARFACTOR
; 
  75   g
->layout_splinefactor 
= G_LAYOUT_SPLINEFACTOR
; 
  77   g
->late_edge_labels 
= G_LATE_EDGE_LABELS
; 
  78   g
->display_edge_labels 
= G_DISPLAY_EDGE_LABELS
; 
  79   g
->dirty_edge_labels 
= G_DIRTY_EDGE_LABELS
; 
  80   g
->finetuning 
= G_FINETUNING
; 
  81   g
->ignore_singles 
= G_IGNORE_SINGLES
; 
  82   g
->straight_phase 
= G_STRAIGHT_PHASE
; 
  83   g
->priority_phase 
= G_PRIORITY_PHASE
; 
  84   g
->manhattan_edges 
= G_MANHATTAN_EDGES
; 
  85   g
->smanhattan_edges 
= G_SMANHATTAN_EDGES
; 
  86   g
->near_edges 
= G_NEAR_EDGES
; 
  88   g
->orientation 
= G_ORIENTATION
; 
  89   g
->node_alignement 
= G_NODE_ALIGNEMENT
; 
  90   g
->port_sharing 
= G_PORT_SHARING
; 
  91   g
->arrow_mode 
= G_ARROW_MODE
; 
  92   g
->treefactor 
= G_TREEFACTOR
; 
  93   g
->spreadlevel 
= G_SPREADLEVEL
; 
  94   g
->crossing_weight 
= G_CROSSING_WEIGHT
; 
  95   g
->crossing_phase2 
= G_CROSSING_PHASE2
; 
  96   g
->crossing_optimization 
= G_CROSSING_OPTIMIZATION
; 
 101   g
->splines 
= G_SPLINES
; 
 112   g
->node_list 
= G_NODE_LIST
; 
 113   g
->edge_list 
= G_EDGE_LIST
; 
 119 /* Initialize a node with the defalut values. */ 
 121 new_node (node_t 
*node
) 
 123   node
->title 
= N_TITLE
; 
 124   node
->label 
= N_LABEL
; 
 126   node
->locx 
= N_LOCX
; /* Default unspcified. */ 
 127   node
->locy 
= N_LOCY
; /* Default unspcified. */ 
 129   node
->vertical_order 
= N_VERTICAL_ORDER
;      /* Default unspcified. */ 
 130   node
->horizontal_order 
= N_HORIZONTAL_ORDER
;  /* Default unspcified. */ 
 132   node
->width 
= N_WIDTH
; /* We assume that we can't define it now. */ 
 133   node
->height 
= N_HEIGHT
; /* Also. */ 
 135   node
->shrink 
= N_SHRINK
; 
 136   node
->stretch 
= N_STRETCH
; 
 138   node
->folding 
= N_FOLDING
; /* No explicit default value. */ 
 140   node
->shape 
= N_SHAPE
; 
 141   node
->textmode 
= N_TEXTMODE
; 
 142   node
->borderwidth 
= N_BORDERWIDTH
; 
 144   node
->color 
= N_COLOR
; 
 145   node
->textcolor 
= N_TEXTCOLOR
; 
 146   node
->bordercolor 
= N_BORDERCOLOR
; 
 148   node
->infos
[0] = N_INFOS1
; 
 149   node
->infos
[1] = N_INFOS2
; 
 150   node
->infos
[2] = N_INFOS3
; 
 155 /* Initialize a edge with the defalut values. */ 
 157 new_edge (edge_t 
*edge
) 
 159   edge
->type 
= E_EDGE_TYPE
; 
 161   edge
->sourcename 
= E_SOURCENAME
; 
 162   edge
->targetname 
= E_TARGETNAME
; 
 163   edge
->label 
= E_LABEL
; 
 165   edge
->linestyle 
= E_LINESTYLE
; 
 166   edge
->thickness 
= E_THICKNESS
; 
 168   edge
->class = E_CLASS
; 
 170   edge
->color 
= E_COLOR
; 
 171   edge
->textcolor 
= E_TEXTCOLOR
; 
 172   edge
->arrowcolor 
= E_ARROWCOLOR
; 
 173   edge
->backarrowcolor 
= E_BACKARROWCOLOR
; 
 175   edge
->arrowsize 
= E_ARROWSIZE
; 
 176   edge
->backarrowsize 
= E_BACKARROWSIZE
; 
 177   edge
->arrowstyle 
= E_ARROWSTYLE
; 
 179   edge
->backarrowstyle 
= E_BACKARROWSTYLE
; 
 181   edge
->priority 
= E_PRIORITY
; 
 183   edge
->anchor 
= E_ANCHOR
; 
 185   edge
->horizontal_order 
= E_HORIZONTAL_ORDER
; 
 190 /*----------------------------------------------. 
 192 | Return string corresponding to an enum value. | 
 193 `----------------------------------------------*/ 
 196 get_color_str (enum color_e c
) 
 200     case white
:         return ("white"); 
 201     case blue
:          return ("blue"); 
 202     case red
:           return ("red"); 
 203     case green
:         return ("green"); 
 204     case yellow
:        return ("yellow"); 
 205     case magenta
:       return ("magenta"); 
 206     case cyan
:          return ("cyan"); 
 207     case darkgrey
:      return ("darkgrey"); 
 208     case darkblue
:      return ("darkblue"); 
 209     case darkred
:       return ("darkred"); 
 210     case darkgreen
:     return ("darkgreen"); 
 211     case darkyellow
:    return ("darkyellow"); 
 212     case darkmagenta
:   return ("darkmagenta"); 
 213     case darkcyan
:      return ("darkcyan"); 
 214     case gold
:          return ("gold"); 
 215     case lightgrey
:     return ("lightgrey"); 
 216     case lightblue
:     return ("lightblue"); 
 217     case lightred
:      return ("lightred"); 
 218     case lightgreen
:    return ("lightgreen"); 
 219     case lightyellow
:   return ("lightyellow"); 
 220     case lightmagenta
:  return ("lightmagenta"); 
 221     case lightcyan
:     return ("lightcyan"); 
 222     case lilac
:         return ("lilac"); 
 223     case turquoise
:     return ("turquoise"); 
 224     case aquamarine
:    return ("aquamarine"); 
 225     case khaki
:         return ("khaki"); 
 226     case purple
:        return ("purple"); 
 227     case yellowgreen
:   return ("yellowgreen"); 
 228     case pink
:          return ("pink"); 
 229     case orange
:        return ("orange"); 
 230     case orchid
:        return ("orchid"); 
 231     case black
:         return ("black"); 
 233       complain (_("vcg graph: no such a color.")); 
 234       return (get_color_str(G_COLOR
)); 
 240 get_textmode_str (enum textmode_e t
) 
 244     case centered
:      return ("center"); 
 245     case left_justify
:  return ("left_justify"); 
 246     case right_justify
: return ("right_justify"); 
 248       complain (_("vcg graph: no such a text mode..")); 
 249       return (get_textmode_str(G_TEXTMODE
)); 
 255 get_shape_str (enum shape_e s
) 
 259     case box
:           return ("box"); 
 260     case rhomb
:         return ("rhomb"); 
 261     case ellipse
:       return ("ellipse"); 
 262     case triangle
:      return ("triangle"); 
 264       complain (_("vcg graph: no such a shape..")); 
 265       return (get_shape_str(G_SHAPE
)); 
 271 get_layoutalgorithm_str (enum layoutalgorithm_e l
) 
 275     case normal
:        return ("normal");  
 276     case maxdepth
:      return ("maxdepth"); 
 277     case mindepth
:      return ("mindepth"); 
 278     case maxdepthslow
:  return ("maxdepthslow"); 
 279     case mindepthslow
:  return ("mindepthslow"); 
 280     case maxdegree
:     return ("maxdegree"); 
 281     case mindegree
:     return ("mindegree"); 
 282     case maxindegree
:   return ("maxindegree"); 
 283     case minindegree
:   return ("minindegree"); 
 284     case maxoutdegree
:  return ("maxoutdegree"); 
 285     case minoutdegree
:  return ("minoutdegree"); 
 286     case minbackward
:   return ("minbackward"); 
 287     case dfs
:           return ("dfs"); 
 288     case tree
:          return ("tree"); 
 296 get_decision_str (enum decision_e d
, enum decision_e defaults
) 
 300     case no
:    return ("no"); 
 301     case yes
:   return ("yes"); 
 303       complain (_("vcg graph: no such a decision..")); 
 304       return (get_decision_str(defaults
, 0)); 
 310 get_orientation_str (enum orientation_e o
) 
 314     case top_to_bottom
: return ("top_to_bottom"); 
 315     case bottom_to_top
: return ("bottom_to_top"); 
 316     case left_to_right
: return ("left_to_right"); 
 317     case right_to_left
: return ("right_to_left"); 
 319       complain (_("vcg graph: no such an orientation..")); 
 320       return (get_orientation_str(G_ORIENTATION
)); 
 326 get_node_alignement_str (enum alignement_e a
) 
 330     case center
:        return ("center"); 
 331     case top
:           return ("top"); 
 332     case bottom
:        return ("bottom"); 
 334       complain (_("vcg graph: no such an alignement..")); 
 335       return (get_node_alignement_str(G_NODE_ALIGNEMENT
)); 
 341 get_arrow_mode_str (enum arrow_mode_e a
) 
 345     case fixed
:         return ("fixed"); 
 346     case free_a
:        return ("free"); 
 348       complain (_("vcg graph: no such an arrow mode..")); 
 349       return (get_arrow_mode_str(G_ARROW_MODE
)); 
 355 get_crossing_type_str (enum crossing_type_e c
) 
 359     case bary
:          return ("bary"); 
 360     case median
:        return ("median"); 
 361     case barymedian
:    return ("barymedian"); 
 362     case medianbary
:    return ("medianbary"); 
 364       complain (_("vcg graph: no such a crossing_type..")); 
 365       return (get_crossing_type_str(G_CROSSING_WEIGHT
));   
 371 get_view_str (enum view_e v
) 
 375     case normal_view
:   return ("normal_view"); 
 376     case cfish
:         return ("cfish"); 
 377     case pfish
:         return ("pfish"); 
 378     case fcfish
:        return ("fcfish"); 
 379     case fpfish
:        return ("fpfish"); 
 381       complain (_("vcg graph: no such a view..")); 
 382       return (get_view_str(G_VIEW
));   
 388 get_linestyle_str (enum linestyle_e l
) 
 392     case continuous
:    return ("continuous"); 
 393     case dashed
:        return ("dashed"); 
 394     case dotted
:        return ("dotted"); 
 395     case invisible
:     return ("invisible"); 
 397       complain (_("vcg graph: no such a linestyle..")); 
 398       return (get_linestyle_str(E_LINESTYLE
));   
 404 get_arrowstyle_str (enum arrowstyle_e a
) 
 408     case solid
: return ("solid"); 
 409     case line
:  return ("line"); 
 410     case none
:  return ("none"); 
 412       complain (_("vcg graph: no such an arrowstyle..")); 
 413       return (get_arrowstyle_str(E_ARROWSTYLE
));   
 418 /*----------------------------. 
 420 | Edge and Nodes int a graph. | 
 421 `----------------------------*/ 
 424 add_node (graph_t 
*graph
, node_t 
*node
) 
 426   node
->next 
= graph
->node_list
; 
 427   graph
->node_list 
= node
; 
 431 add_edge (graph_t 
*graph
, edge_t 
*edge
) 
 433   edge
->next 
= graph
->edge_list
; 
 434   graph
->edge_list 
= edge
; 
 437 /*-------------------------------------. 
 438 | Open and close functions (formatted) | 
 439 `-------------------------------------*/ 
 442 open_edge(edge_t 
*edge
, struct obstack 
*os
) 
 447       obstack_sgrow (os
, "\tedge: {\n"); 
 450       obstack_sgrow (os
, "\tbackedge: {\n"); 
 453       obstack_sgrow (os
, "\tnearedge: {\n"); 
 456       obstack_sgrow (os
, "\tbentnearedge: {\n"); 
 459       obstack_sgrow (os
, "\tedge: {\n"); 
 464 close_edge(struct obstack 
*os
) 
 466   obstack_sgrow (os
, "\t}\n");     
 470 open_node(struct obstack 
*os
) 
 472   obstack_sgrow (os
, "\tnode: {\n"); 
 476 close_node(struct obstack 
*os
) 
 478   obstack_sgrow (os
, "\t}\n"); 
 482 open_graph(struct obstack 
*os
) 
 484   obstack_sgrow (os
, "graph: {\n"); 
 488 close_graph(graph_t 
*graph
, struct obstack 
*os
) 
 490   obstack_1grow (os
, '\n'); 
 495     for (node 
= graph
->node_list
; node
; node 
= node
->next
) 
 498         output_node (node
, os
); 
 503   obstack_1grow (os
, '\n'); 
 508     for (edge 
= graph
->edge_list
; edge
; edge 
= edge
->next
) 
 510         open_edge (edge
, os
); 
 511         output_edge (edge
, os
); 
 516   obstack_sgrow (os
, "}\n"); 
 519 /*-------------------------------------------. 
 520 | Output functions (formatted) in obstack os | 
 521 `-------------------------------------------*/ 
 524 output_node (node_t 
*node
, struct obstack 
*os
) 
 526   if (node
->title 
!= N_TITLE
) 
 527     obstack_fgrow1 (os
, "\t\ttitle:\t\"%s\"\n", node
->title
); 
 528   if (node
->label 
!= N_LABEL
) 
 529     obstack_fgrow1 (os
, "\t\tlabel:\t\"%s\"\n", node
->label
); 
 531   if ((node
->locx 
!= N_LOCX
) && (node
->locy 
!= N_LOCY
)) 
 532     obstack_fgrow2 (os
, "\t\tloc { x: %d  y: %d }\t\n", node
->locx
, node
->locy
); 
 534   if (node
->vertical_order 
!= N_VERTICAL_ORDER
) 
 535     obstack_fgrow1 (os
, "\t\tvertical_order:\t%d\n", node
->vertical_order
); 
 536   if (node
->horizontal_order 
!= N_HORIZONTAL_ORDER
) 
 537     obstack_fgrow1 (os
, "\t\thorizontal_order:\t%d\n", node
->horizontal_order
); 
 539   if (node
->width 
!= N_WIDTH
) 
 540     obstack_fgrow1 (os
, "\t\twidth:\t%d\n", node
->width
); 
 541   if (node
->height 
!= N_HEIGHT
) 
 542     obstack_fgrow1 (os
, "\t\theight:\t%d\n", node
->height
); 
 544   if (node
->shrink 
!= N_SHRINK
) 
 545     obstack_fgrow1 (os
, "\t\tshrink:\t%d\n", node
->shrink
); 
 546   if (node
->stretch 
!= N_STRETCH
) 
 547     obstack_fgrow1 (os
, "\t\tshrink:\t%d\n", node
->shrink
); 
 549   if (node
->folding 
!= N_FOLDING
) 
 550     obstack_fgrow1 (os
, "\t\tfolding:\t%d\n", node
->folding
);   
 552   if (node
->textmode 
!= N_TEXTMODE
) 
 553     obstack_fgrow1 (os
, "\t\ttextmode:\t%s\n",  
 554                     get_textmode_str (node
->textmode
)); 
 556   if (node
->shape 
!= N_SHAPE
) 
 557     obstack_fgrow1 (os
, "\t\tshape:\t%s\n", get_shape_str (node
->shape
)); 
 559   if (node
->borderwidth 
!= N_BORDERWIDTH
) 
 560     obstack_fgrow1 (os
, "\t\tborderwidth:\t%d\n", node
->borderwidth
); 
 562   if (node
->color 
!= N_COLOR
) 
 563     obstack_fgrow1 (os
, "\t\tcolor:\t%s\n", get_color_str (node
->color
)); 
 564   if (node
->textcolor 
!= N_TEXTCOLOR
) 
 565     obstack_fgrow1 (os
, "\t\ttextcolor:\t%s\n",  
 566                     get_color_str (node
->textcolor
)); 
 567   if (node
->bordercolor 
!= N_BORDERCOLOR
) 
 568     obstack_fgrow1 (os
, "\t\tbordercolor:\t%s\n",  
 569                     get_color_str (node
->bordercolor
)); 
 572     obstack_fgrow1 (os
, "\t\tinfo1:\t\"%s\"\n", node
->infos
[0]); 
 574     obstack_fgrow1 (os
, "\t\tinfo2:\t\"%s\"\n", node
->infos
[1]); 
 576     obstack_fgrow1 (os
, "\t\tinfo3:\t\"%s\"\n", node
->infos
[2]); 
 580 output_edge (edge_t 
*edge
, struct obstack 
*os
) 
 583   if (edge
->sourcename 
!= E_SOURCENAME
) 
 584     obstack_fgrow1 (os
, "\t\tsourcename:\t\"%s\"\n", edge
->sourcename
); 
 585   if (edge
->targetname 
!= E_TARGETNAME
) 
 586     obstack_fgrow1 (os
, "\t\ttargetname:\t\"%s\"\n", edge
->targetname
); 
 588   if (edge
->label 
!= E_LABEL
) 
 589     obstack_fgrow1 (os
, "\t\tlabel:\t\"%s\"\n", edge
->label
); 
 591   if (edge
->linestyle 
!= E_LINESTYLE
) 
 592     obstack_fgrow1 (os
, "\t\tlinestyle:\t\"%s\"\n",  
 593                     get_linestyle_str(edge
->linestyle
)); 
 595   if (edge
->thickness 
!= E_THICKNESS
) 
 596     obstack_fgrow1 (os
, "\t\tthickness:\t%d\n", edge
->thickness
); 
 597   if (edge
->class != E_CLASS
) 
 598     obstack_fgrow1 (os
, "\t\tclass:\t%d\n", edge
->class); 
 600   if (edge
->color 
!= E_COLOR
) 
 601     obstack_fgrow1 (os
, "\t\tcolor:\t%s\n", get_color_str (edge
->color
)); 
 602   if (edge
->color 
!= E_TEXTCOLOR
) 
 603     obstack_fgrow1 (os
, "\t\ttextcolor:\t%s\n",  
 604                     get_color_str (edge
->textcolor
)); 
 605   if (edge
->arrowcolor 
!= E_ARROWCOLOR
) 
 606     obstack_fgrow1 (os
, "\t\tarrowcolor:\t%s\n",  
 607                     get_color_str (edge
->arrowcolor
)); 
 608   if (edge
->backarrowcolor 
!= E_BACKARROWCOLOR
) 
 609     obstack_fgrow1 (os
, "\t\tbackarrowcolor:\t%s\n",  
 610                     get_color_str (edge
->backarrowcolor
)); 
 612   if (edge
->arrowsize 
!= E_ARROWSIZE
) 
 613     obstack_fgrow1 (os
, "\t\tarrowsize:\t%d\n", edge
->arrowsize
); 
 614   if (edge
->backarrowsize 
!= E_BACKARROWSIZE
) 
 615     obstack_fgrow1 (os
, "\t\tbackarrowsize:\t%d\n", edge
->backarrowsize
); 
 617   if (edge
->arrowstyle 
!= E_ARROWSTYLE
) 
 618     obstack_fgrow1 (os
, "\t\tarrowstyle:\t%s\n",  
 619                     get_arrowstyle_str(edge
->arrowstyle
)); 
 620   if (edge
->backarrowstyle 
!= E_BACKARROWSTYLE
) 
 621     obstack_fgrow1 (os
, "\t\tbackarrowstyle:\t%s\n",  
 622                     get_arrowstyle_str(edge
->backarrowstyle
)); 
 624   if (edge
->priority 
!= E_PRIORITY
) 
 625     obstack_fgrow1 (os
, "\t\tpriority:\t%d\n", edge
->priority
); 
 626   if (edge
->anchor 
!= E_ANCHOR
) 
 627     obstack_fgrow1 (os
, "\t\tanchor:\t%d\n", edge
->anchor
); 
 628   if (edge
->horizontal_order 
!= E_HORIZONTAL_ORDER
) 
 629     obstack_fgrow1 (os
, "\t\thorizontal_order:\t%d\n", edge
->horizontal_order
); 
 633 output_graph (graph_t 
*graph
, struct obstack 
*os
) 
 636     obstack_fgrow1 (os
, "\ttitle:\t\"%s\"\n", graph
->title
); 
 638     obstack_fgrow1 (os
, "\tlabel:\t\"%s\"\n", graph
->label
); 
 641     obstack_fgrow1 (os
, "\tinfo1:\t\"%s\"\n", graph
->infos
[0]); 
 643     obstack_fgrow1 (os
, "\tinfo2:\t\"%s\"\n", graph
->infos
[1]); 
 645     obstack_fgrow1 (os
, "\tinfo3:\t\"%s\"\n", graph
->infos
[2]); 
 647   if (graph
->color 
!= G_COLOR
) 
 648     obstack_fgrow1 (os
, "\tcolor:\t%s\n", get_color_str (graph
->color
)); 
 649   if (graph
->textcolor 
!= G_TEXTCOLOR
) 
 650     obstack_fgrow1 (os
, "\ttextcolor:\t%s\n", get_color_str (graph
->textcolor
)); 
 651   if (graph
->bordercolor 
!= G_BORDERCOLOR
) 
 652     obstack_fgrow1 (os
, "\tbordercolor:\t%s\n",  
 653                     get_color_str (graph
->bordercolor
)); 
 655   if (graph
->width 
!= G_WIDTH
) 
 656     obstack_fgrow1 (os
, "\twidth:\t%d\n", graph
->width
); 
 657   if (graph
->height 
!= G_HEIGHT
) 
 658     obstack_fgrow1 (os
, "\theight:\t%d\n", graph
->height
); 
 659   if (graph
->borderwidth 
!= G_BORDERWIDTH
) 
 660     obstack_fgrow1 (os
, "\tborderwidth:\t%d\n", graph
->borderwidth
); 
 663     obstack_fgrow1 (os
, "\tx:\t%d\n", graph
->x
); 
 665     obstack_fgrow1 (os
, "\ty:\t%d\n", graph
->y
); 
 667   if (graph
->folding 
!= G_FOLDING
) 
 668     obstack_fgrow1 (os
, "\tfolding:\t%d\n", graph
->folding
); 
 670   if (graph
->shrink 
!= G_SHRINK
) 
 671     obstack_fgrow1 (os
, "\tshrink:\t%d\n", graph
->shrink
); 
 672   if (graph
->stretch 
!= G_STRETCH
) 
 673     obstack_fgrow1 (os
, "\tstretch:\t%d\n", graph
->stretch
); 
 675   if (graph
->textmode 
!= G_TEXTMODE
) 
 676     obstack_fgrow1 (os
, "\ttextmode:\t%s\n",  
 677                     get_textmode_str (graph
->textmode
)); 
 679   if (graph
->shape 
!= G_SHAPE
) 
 680     obstack_fgrow1 (os
, "\tshape:\t%s\n", get_shape_str (graph
->shape
)); 
 682   if (graph
->xmax 
!= G_XMAX
) 
 683     obstack_fgrow1 (os
, "\txmax:\t%d\n", graph
->xmax
); 
 684   if (graph
->ymax 
!= G_YMAX
) 
 685     obstack_fgrow1 (os
, "\tymax:\t%d\n", graph
->ymax
); 
 687   if (graph
->xbase 
!= G_XBASE
) 
 688     obstack_fgrow1 (os
, "\txbase:\t%d\n", graph
->xbase
); 
 689   if (graph
->ybase 
!= G_YBASE
) 
 690     obstack_fgrow1 (os
, "\tybase:\t%d\n", graph
->ybase
); 
 692   if (graph
->xspace 
!= G_XSPACE
) 
 693     obstack_fgrow1 (os
, "\txspace:\t%d\n", graph
->xspace
); 
 694   if (graph
->yspace 
!= G_YSPACE
) 
 695     obstack_fgrow1 (os
, "\tyspace:\t%d\n", graph
->yspace
); 
 696   if (graph
->xlspace 
!= G_XLSPACE
) 
 697     obstack_fgrow1 (os
, "\txlspace:\t%d\n", graph
->xlspace
); 
 699   if (graph
->xraster 
!= G_XRASTER
) 
 700     obstack_fgrow1 (os
, "\txraster:\t%d\n", graph
->xraster
); 
 701   if (graph
->yraster 
!= G_YRASTER
) 
 702     obstack_fgrow1 (os
, "\tyraster:\t%d\n", graph
->yraster
); 
 703   if (graph
->xlraster 
!= G_XLRASTER
) 
 704     obstack_fgrow1 (os
, "\txlraster:\t%d\n", graph
->xlraster
); 
 706   if (graph
->hidden 
!= G_HIDDEN
) 
 707     obstack_fgrow1 (os
, "\thidden:\t%d\n", graph
->hidden
); 
 709   if (graph
->classname 
!= G_CLASSNAME
) 
 711       struct classname_s 
*ite
; 
 713       for (ite 
= graph
->classname
; ite
; ite 
= ite
->next
) 
 714         obstack_fgrow2 (os
, "\tclassname %d :\t%s\n", ite
->no
, ite
->name
); 
 717   if (graph
->layoutalgorithm 
!= G_LAYOUTALGORITHM
) 
 718     obstack_fgrow1 (os
, "\tlayoutalgorithm:\t%s\n",  
 719                     get_layoutalgorithm_str(graph
->layoutalgorithm
)); 
 721   if (graph
->layout_downfactor 
!= G_LAYOUT_DOWNFACTOR
) 
 722     obstack_fgrow1 (os
, "\tlayout_downfactor:\t%d\n", graph
->layout_downfactor
); 
 723   if (graph
->layout_upfactor 
!= G_LAYOUT_UPFACTOR
) 
 724     obstack_fgrow1 (os
, "\tlayout_upfactor:\t%d\n", graph
->layout_upfactor
);   
 725   if (graph
->layout_nearfactor 
!= G_LAYOUT_NEARFACTOR
) 
 726     obstack_fgrow1 (os
, "\tlayout_nearfactor:\t%d\n", graph
->layout_nearfactor
); 
 727   if (graph
->layout_splinefactor 
!= G_LAYOUT_SPLINEFACTOR
) 
 728     obstack_fgrow1 (os
, "\tlayout_splinefactor:\t%d\n",  
 729                     graph
->layout_splinefactor
); 
 731   if (graph
->late_edge_labels 
!= G_LATE_EDGE_LABELS
) 
 732     obstack_fgrow1 (os
, "\tlate_edge_labels:\t%s\n",  
 733                     get_decision_str(graph
->late_edge_labels
,  
 734                                      G_LATE_EDGE_LABELS
)); 
 735   if (graph
->display_edge_labels 
!= G_DISPLAY_EDGE_LABELS
) 
 736     obstack_fgrow1 (os
, "\tdisplay_edge_labels:\t%s\n",  
 737                     get_decision_str(graph
->display_edge_labels
,  
 738                                      G_DISPLAY_EDGE_LABELS
)); 
 739   if (graph
->dirty_edge_labels 
!= G_DIRTY_EDGE_LABELS
) 
 740     obstack_fgrow1 (os
, "\tdirty_edge_labels:\t%s\n",  
 741                     get_decision_str(graph
->dirty_edge_labels
,  
 742                                      G_DIRTY_EDGE_LABELS
)); 
 743   if (graph
->finetuning 
!= G_FINETUNING
) 
 744     obstack_fgrow1 (os
, "\tfinetuning:\t%s\n",  
 745                     get_decision_str(graph
->finetuning
, G_FINETUNING
)); 
 746   if (graph
->ignore_singles 
!= G_IGNORE_SINGLES
) 
 747     obstack_fgrow1 (os
, "\tignore_singles:\t%s\n",  
 748                     get_decision_str(graph
->ignore_singles
, G_IGNORE_SINGLES
)); 
 749   if (graph
->straight_phase 
!= G_STRAIGHT_PHASE
) 
 750     obstack_fgrow1 (os
, "\tstraight_phase:\t%s\n",  
 751                     get_decision_str(graph
->straight_phase
, G_STRAIGHT_PHASE
)); 
 752   if (graph
->priority_phase 
!= G_PRIORITY_PHASE
) 
 753     obstack_fgrow1 (os
, "\tpriority_phase:\t%s\n",  
 754                     get_decision_str(graph
->priority_phase
, G_PRIORITY_PHASE
)); 
 755   if (graph
->manhattan_edges 
!= G_MANHATTAN_EDGES
) 
 757                     "\tmanhattan_edges:\t%s\n",  
 758                     get_decision_str(graph
->manhattan_edges
,  
 760   if (graph
->smanhattan_edges 
!= G_SMANHATTAN_EDGES
) 
 762                     "\tsmanhattan_edges:\t%s\n",  
 763                     get_decision_str(graph
->smanhattan_edges
,  
 764                                      G_SMANHATTAN_EDGES
)); 
 765   if (graph
->near_edges 
!= G_NEAR_EDGES
) 
 766     obstack_fgrow1 (os
, "\tnear_edges:\t%s\n",  
 767                     get_decision_str(graph
->near_edges
, G_NEAR_EDGES
)); 
 769   if (graph
->orientation 
!= G_ORIENTATION
) 
 770     obstack_fgrow1 (os
, "\torientation:\t%s\n",  
 771                     get_decision_str(graph
->orientation
, G_ORIENTATION
)); 
 773   if (graph
->node_alignement 
!= G_NODE_ALIGNEMENT
) 
 774     obstack_fgrow1 (os
, "\tnode_alignement:\t%s\n",  
 775                     get_decision_str(graph
->node_alignement
,  
 778   if (graph
->port_sharing 
!= G_PORT_SHARING
) 
 779     obstack_fgrow1 (os
, "\tport_sharing:\t%s\n",  
 780                     get_decision_str(graph
->port_sharing
, G_PORT_SHARING
)); 
 782   if (graph
->arrow_mode 
!= G_ARROW_MODE
) 
 783     obstack_fgrow1 (os
, "\tarrow_mode:\t%s\n",  
 784                     get_arrow_mode_str(graph
->arrow_mode
)); 
 786   if (graph
->treefactor 
!= G_TREEFACTOR
) 
 787     obstack_fgrow1 (os
, "\ttreefactor:\t%f\n", graph
->treefactor
); 
 788   if (graph
->spreadlevel 
!= G_SPREADLEVEL
) 
 789     obstack_fgrow1 (os
, "\tspreadlevel:\t%d\n", graph
->spreadlevel
); 
 791   if (graph
->crossing_weight 
!= G_CROSSING_WEIGHT
) 
 792     obstack_fgrow1 (os
, "\tcrossing_weight:\t%s\n",  
 793                     get_crossing_type_str(graph
->crossing_weight
)); 
 794   if (graph
->crossing_phase2 
!= G_CROSSING_PHASE2
) 
 795     obstack_fgrow1 (os
, "\tcrossing_phase2:\t%s\n",  
 796                     get_decision_str(graph
->crossing_phase2
,  
 798   if (graph
->crossing_optimization 
!= G_CROSSING_OPTIMIZATION
) 
 799     obstack_fgrow1 (os
, "\tcrossing_optimization:\t%s\n",  
 800                     get_decision_str(graph
->crossing_optimization
,  
 801                                      G_CROSSING_OPTIMIZATION
)); 
 803   if (graph
->view 
!= G_VIEW
) 
 804     obstack_fgrow1 (os
, "\tview:\t%s\n", get_view_str(graph
->view
)); 
 806   if (graph
->edges 
!= G_EDGES
) 
 807     obstack_fgrow1 (os
, "\tedges:\t%s\n", get_decision_str(graph
->edges
,  
 810   if (graph
->nodes 
!= G_NODES
) 
 811     obstack_fgrow1 (os
,"\tnodes:\t%s\n",  
 812                     get_decision_str(graph
->nodes
, G_NODES
));   
 814   if (graph
->splines 
!= G_SPLINES
) 
 815     obstack_fgrow1 (os
, "\tsplines:\t%s\n",  
 816                     get_decision_str(graph
->splines
, G_SPLINES
)); 
 818   if (graph
->bmax 
!= G_BMAX
) 
 819     obstack_fgrow1 (os
, "\tbmax:\t%d\n", graph
->bmax
);     
 820   if (graph
->cmin 
!= G_CMIN
) 
 821     obstack_fgrow1 (os
, "\tcmin:\t%d\n", graph
->cmin
);     
 822   if (graph
->cmax 
!= G_CMAX
) 
 823     obstack_fgrow1 (os
, "\tcmax:\t%d\n", graph
->cmax
);     
 824   if (graph
->pmin 
!= G_PMIN
) 
 825     obstack_fgrow1 (os
, "\tpmin:\t%d\n", graph
->pmin
);     
 826   if (graph
->pmax 
!= G_PMAX
) 
 827     obstack_fgrow1 (os
, "\tpmax:\t%d\n", graph
->pmax
);     
 828   if (graph
->rmin 
!= G_RMIN
) 
 829     obstack_fgrow1 (os
, "\trmin:\t%d\n", graph
->rmin
);     
 830   if (graph
->rmax 
!= G_RMAX
) 
 831     obstack_fgrow1 (os
, "\trmax:\t%d\n", graph
->rmax
);     
 832   if (graph
->smax 
!= G_SMAX
) 
 833     obstack_fgrow1 (os
, "\tsmax:\t%d\n", graph
->smax
);     
 843   struct obstack graph_obstack
; 
 845   obstack_init (&graph_obstack
); 
 849   graph
.title 
= "graph_title"; 
 850   graph
.label 
= "graph_label"; 
 851   graph
.color 
= yellow
; 
 852   graph
.textcolor 
= green
; 
 856   graph
.textmode 
= right_justify
; 
 858   open_graph (&graph
, stdout
); 
 860   node 
= XMALLOC (node_t
, 1); 
 865   add_node (&graph
, node
); 
 867   node 
= XMALLOC (node_t
, 1); 
 870   add_node (&graph
, node
); 
 872   edge 
= XMALLOC (edge_t
, 1); 
 874   edge
->sourcename 
= "B"; 
 875   edge
->targetname 
= "A"; 
 876   add_edge (&graph
, edge
); 
 878   output_graph(&graph
, stdout
); 
 879   close_graph (&graph
, stdout
); 
 881   obstack_save (&graph_obstack
, "essai.vcg"); 
 886 #endif /* not DEBUG */