Debian Codegraph @

lib/mlrisc-lib/MLRISC/Doc/latex/graphics.tex

raw
1 \section{The Graph Visualization Library}
2 \subsection{Overview}
3 Visualization is an important aid for debugging graph algorithms.
4 MLRISC provides a simple facility for displaying graphs that
5 adheres to the graph interface. Two graph viewer
6 back-ends are currently supported. (An interface to the \emph{dot}
7 tool is still available but is unsupported.)
8 \begin{itemize}
9 \item \externhref{http://www.cs.uni-sb.de/RW/users/sander/html/gsvcg1.html}{vcg} --
10 this tool supports the browsing
11 of hierarchical graphs, zoom in/zoom out functions. It can
12 handle up to around 5000 nodes in a graph.
13 \item \externhref{http://www.Informatik.Uni-Bremen.DE/~davinci/}{daVinci} --
14 this tool supports a separate
15 ``survey'' view from the main view and text searching. This tool is
16 slower than vcg but it has a nicer interface, and
17 can handle up to around 500 nodes in a graph.
18 \end{itemize}
19 All graph viewing back-ends work in the same manner.
20 They take a graph whose nodes and edges are annotated with \newdef{layout}
21 instructions and translate these layout instructions
22 into the target description language. For vcg, the target description
23 language is GDL. For daVinci, it is a language based on s-expressions.
24
25 \subsection{Graph Layout}
26 Some basic layout formats are defined structure \sml{GraphLayout} are:
27 \begin{SML}
28 structure \mlrischref{visualization/graphLayout.sml}{GraphLayout} = struct
29 datatype format =
30 LABEL of string
31 | COLOR of string
32 | NODE_COLOR of string
33 | EDGE_COLOR of string
34 | TEXT_COLOR of string
35 | ARROW_COLOR of string
36 | BACKARROW_COLOR of string
37 | BORDER_COLOR of string
38 | BORDERLESS
39 | SHAPE of string
40 | ALGORITHM of string
41 | EDGEPATTERN of string
42
43 type ('n,'e,'g) style =
44 \{ edge : 'e edge -> format list,
45 node : 'n node -> format list,
46 graph : 'g -> format list
47 \}
48 type layout = (format list, format list, format list) graph
49 end
50 \end{SML}
51
52 The interpretation of the layout formats are as follows:
53 \begin{center}
54 \begin{tabular}{|l|l|} \hline
55 \sml{LABEL} $l$ & Label a node or an edge with the string $l$ \\
56 \sml{COLOR} $c$ & Use color $c$ for a node or an edge \\
57 \sml{NODE_COLOR} $c$ & Use color $c$ for a node \\
58 \sml{EDGE_COLOR} $c$ & Use color $c$ for an edge \\
59 \sml{TEXT_COLOR} $c$ & Use color $c$ for the text within a node \\
60 \sml{ARROW_COLOR} $c$ & Use color $c$ for the arrow of an edge \\
61 \sml{BACKARROW_COLOR} $c$ & Use color $c$ for the arrow of an edge \\
62 \sml{BORDER_COLOR} $c$ & Use color $c$ for the border in a node \\
63 \sml{BORDERLESS} & Disable border for a node \\
64 \sml{SHAPE} $s$ & Use shape $s$ for a node \\
65 \sml{ALGORITHM} $a$ & Use algorithm $a$ to layout the graph \\
66 \sml{EDGEPATTERN} $p$ & Use pattern $p$ to layout an edge \\
67 \hline
68 \end{tabular}
69 \end{center}
70
71 Exactly how these formats are interpreted is determined by
72 the visualization tool that is used. If a feature is unsupported
73 then the corresponding format will be ignored.
74 Please see the appropriate reference manuals of vcg and daVinci for details.
75
76 \subsection{Layout style}
77 How a graph is layout is determined by its \newdef{layout style}:
78 \begin{SML}
79 type ('n,'e,'g) style =
80 \{ edge : 'e edge -> format list,
81 node : 'n node -> format list,
82 graph : 'g -> format list
83 \}
84 \end{SML}
85 which is simply three functions that convert nodes, edges and graph
86 info into layout formats.
87 The function \sml{makeLayout} can be used to convert a
88 layout style into a layout, which can then be passed to a graph
89 viewer to be displayed.
90 \begin{SML}
91 GraphLayout.makeLayout : ('n,'e,'g) style -> ('n,'e,'g) graph -> layout
92 \end{SML}
93
94 \subsection{Graph Displays}
95
96 A \newdef{graph display} is an abstraction for the
97 interface that converts a layout graph into an external graph
98 description language. This abstraction is defined in the
99 signature below.
100 \begin{SML}
101 signature \mlrischref{visualization/graphDisplay.sig}{GRAPH_DISPLAY} = sig
102 val suffix : unit -> string
103 val program : unit -> string
104 val visualize : (string -> unit) -> GraphLayout.layout -> unit
105 end
106 \end{SML}
107 \begin{itemize}
108 \item \sml{suffix} is the common file suffix used for the graph description
109 language
110 \item \sml{program} is the common name of the graph visualization tool
111 \item \sml{visualize} is a function that takes a
112 string output function and a layout graph $G$ as arguments
113 and generates a graph description based on $G$
114 \end{itemize}
115
116 \subsection{Graph Viewers}
117
118 The graph viewer functor
119 \mlrischref{visualization/graphViewer.sml}{GraphViewer}
120 takes a graph display back-end and creates a graph viewer
121 that can be used to display any layout graph.
122
123 \begin{SML}
124 signature \mlrischref{visualization/graphViewer.sig}{GRAPH_VIEWER} = sig
125 val view : GraphLayout.layout -> unit
126 end
127 functor GraphViewer(D : GRAPH_DISPLAY) : GRAPH_VIEWER
128 \end{SML}