On the Automated Drawing of Graphs - CiteSeerX

3 downloads 0 Views 81KB Size Report
represent a simple class of planar graphs) in which a centriodal vertex is easily .... an axis of symmetry for some representation of the graph in the plane.
Proceedings of the Third Caribbean Conference on Combinatorics and Computing The University of the West Indies, Barbados, pp 43 – 55, 1981

On the Automated Drawing of Graphs Margaret A. Bernard Department of Mathematics The University of the West Indies Trinidad Abstract The author has designed a computer system for the automated drawing of graphs. This transforms a graph from its algebraic description to a visual representation in the plane, displaying a selected property. This paper considers some aspects of that work, outlining the procedure for the automatic drawing of trees, and graphs displaying symmetry properties

1. INTRODUCTION A graph is defined as an abstract algebraic structure; however, for many problems involving graph-theoretic methods the model graph is required not in its algebraic form but in the visual form of one of its geometric representations in the plane, the particular representation being dependent on the property of the graph under analysis. I have thus designed a computer system for the automated drawing of graphs[ 1 ] using a digital plotter; it transforms a graph from an algebraic description (example, the adjacency matrix) to a drawing in the plane displaying a selected property. For the drawing we must note that in using a digital plotter all lines must be fixed when plotted and cannot be adjusted by an external operator; therefore all decisions concerning the design and layout of the drawing must be made before computing the coordinates of the vertices. The algorithm considers the design, the calculation and the automatic layout and plotting of the drawing. Two very general properties of graphs are considered: planarity and symmetry (symmetry being restricted to the operation of reflection). Thus given any graph (with input as a list of edges) the algorithm tests the graph for the selected property; if the property exists the output on the graph plotter peripheral is then a drawing of the graph displaying the property. An algorithm is also developed to produce a plane drawing for trees (which

represent a simple class of planar graphs) in which a centriodal vertex is easily identified. With further research the computer package can thus be built up to include other properties of graphs. This paper considers some aspects of that work outlining the procedure for the automatic drawing of trees, and graphs displaying symmetry properties INPUT & OUTPUT FORMATS: The input data for the computer package is a list of the edges of the graph as vertex pairs. The output is a drawing of the graph. EXAMPLE: A tree on 40 vertices (39 edges) Input: (5,21) (2,9) (1,8) (39,38) (26,8) (30,28) (9,13) (5,20) (3,1) (32,34) (5,1) (9,12) (32,33) (5,19) (6,1) (27,8) (1,2) (31,8) (1,7) (9,11) (10,9) (28,27) (32,35) (6,25) (2,14) (27,29) (8,32) (37,36) (6,24) (2,15) (16,2) (23,6) (38,40) (32,36) (36,38) (6,22) (16,18) (1,4) (16,17) Output: Fig.3 gives the output for this graph which is a plane drawing of the tree. (Vertex labels are manually inserted.) 2. TREES Definitions: A branch at a vertex v in a tree T is a maximal subtree containing v as a pendant vertex. The weight of a branch is the number of edges in the branch. The weight of a vertex v in T is the maximum number of edges in any branch at v. A vertex v is a centroidal vertex in T if v has minimum weight. The design of the tree drawing is one in which a centroidal vertex c is mapped onto a point at the centre of the drawing; the branches originating at c ‘grow’ outwards giving a virtual direction to the branch. The vertices are mapped onto the circumferences of concentric circles with c as centre such that if i = d (c, vi), the distance of vertex vi from c, then vi is mapped onto the ith concentric circle. All edges are represented by straight lines (Fig. 1).

Fig. 1 TREE DRAWING DESIGN

Identification of the Centroidal Vertex The weight of each vertex is obtained by a modification to the coding procedure for free unlabelled trees developed in [ 2 ]. In the coding the edges are traversed starting from pendant edges, proceeding inwards to a central vertex. The vertices are coded as they are arrived at from the codes of adjacent vertices already searched. Let ci , c2 …. ck be the codes of the k vertices adjacent to vertex v, where ci is a binary string and v is adjacent to at most one other uncoded vertex. Then the number of zeroes in the code of ci (i=1,k) is equivalent to the number of edges traversed in the branch i at the vertex v. The number of edges in the branch leading to the uncoded vertex is equal to E - Σ ci where E is the total number of edges. The weight of vertex v is then the maximum number of edges in any branch at v. The weights of all the vertices are found and a vertex of minimum weight is a centroidal vertex. Drawing Procedure The essential feature of the drawing procedure is the calculation of the Cartesian coordinates of the vertices of the tree. Vertices mapped onto the plane are represented by small circles with centres given by the coordinates calculated for the corresponding vertices. Edges are mapped onto straight line segments joining the end vertices. The centroidal vertex c is fixed at the origin of the Cartesian coordinate system. The coordinates of all other vertices are calculated with respect to this coordinate system.

Vertices adjacent to c are distributed at equal arc distances on the circumference of the first concentric circle (level 1) of fixed radius. Calculation of the coordinates of the other vertices on successive levels require some detailed geometry and really leave the realm of Graph Theory; details of these calculations can be found in [ 1 ]. I will mention just two aspects of these calculations: since every tree is planar it would be appropriate to obtain a plane drawing of the tree. This can be done as will now be described. Consider that we have placed vertices vi , v2 v3 on level j as in Fig. 2, and now require to place vertices adjacent to v2 on level j+1.We place all vertices adjacent to v2 on the arc AB, where CA and CB are bisectors of the angles vi c v2, and v2 c v3 respectively. Thus we avoid any crossings. Also, to avoid congestion in the drawing we space the vertices on the arc AB in proportion to the weights of the branches ‘growing’ outwards at those vertices. Thus branches of greater weights are drawn in larger sectors.

Fig. 2

The algorithm incorporates the procedure for the identification of a centroidal vertex. In the calculation of the coordinates, each vertex is only considered once. The algorithm is optimal having O(v) time bound.

Fig. 3 COMPUTER DRAWING OF A TREE

3. SYMMETRICAL GRAPHS Definitions: Two vertices u and v of a graph G are similar vertices if for some automorphism ∏ of G, ∏ (u) = v. A fixed vertex is a vertex that is not similar to any other vertex. A symmetrical graph is one that contains an axis of symmetry for some representation of the graph in the plane. Many graphs are not completely symmetric (all vertices are similar to each other) but show some degree of symmetry. Therefore the procedure developed for symmetry

drawing considers the broader class of graphs that consists of pairs of similar vertices and some fixed vertices. Such graphs (called symmetrical graphs) display the symmetry operation of reflection; they possess an axis of symmetry that is a line of reflection showing pairs of similar vertices as mirror images of each other. The procedure for symmetry recognition involves identifying similar vertices such that permutations of the labels leave the connectivity invariant. No prior knowledge of symmetry operation is required. Essentially the search for an axis of symmetry in a graph is to identify the pairs of similar vertices and the fixed vertices representing the axis. In order to determine the similar vertices, the vertices of the graph are classified according to adjacency properties such that pairs of vertices with similar properties are identified. The labels of these vertices are then permuted and the adjacency matrix formed is analyzed. If the matrix is unaltered then the pairs of vertices with similar properties are similar vertices. Having identified the pairs of similar vertices and fixed vertices a symmetry drawing is obtained displaying a line of reflection in the graph along the axis of symmetry. The representation of the symmetrical graph that is given by the algorithm is a mapping in which each fixed vertex is mapped onto a point in the plane forming a straight line (an axis) and the pairs of similar vertices mapped onto points on both sides of that axis at fixed, perpendicular distances. Each edge is represented by a straight line segment joining the images of its end points (FIG. 4). For the classification of the vertices of the graph the procedure used is one developed in [ 3 ]. The vertices of the graph are classified according to their adjacency properties such that vertices with similar properties are in the same class. For each class, we define the size of the class as the number of vertices in the class. Input : (1,3) (4,10) (8,9) (8,10) (3,10) (7,8) (1,2) (5,6) (2,5) (1,4) (6,7) (6,8) (3,4) (5,7)

Fig. 4 COMPUTER DRAWING OF A SYMMETRICAL GRAPH

Symmetry Recognition Algorithm Initially, vertices with equal valencies are in the same class. Step 1 Apply classification procedure until there are no further changes in the classification. If each class is of size one then terminate algorithm. If there are at least two classes of size one then go to step 3 If there are less than two classes of size one then go to step 2.

Step 2 Systematically investigate vertices subject to specified conditions* to identify a pair of vertices for the axis (if no axis of symmetry can be found, algorithm terminates). Put these vertices in distinct classes (of size 1) and reapply classification procedure. Go to step 3 Step 3 If there are classes of sizes greater than 2, partition the vertices in the given class into pairs (u, v) ( and one fixed vertex for classes of odd size) such that u and v are adjacent to an even number of vertices in common (not including fixed vertices). Go to step 4 Step 4 Construct the adjacency matrix by permuting the labels of vertices in classes of size two, leaving those in classes of size 1 unaltered; compare with the original matrix. If the matrices are the same, proceed to the drawing procedure.

*Conditions to identify a pair of vertices (u, v) which form the ends of an axis of symmetry 1. For a graph with an even number of vertices, vertices u and v are from the same class if the size of that class is even; otherwise they are from different classes. 2. If the valency of either u or v is even, then u is not adjacent to v. 3. Both vertices u and v are adjacent to an even number of vertices in any given class (excluding fixed vertices). 4. Vertices u and v are adjacent to an even number of vertices in common (excluding fixed vertices). The initial classification procedure is O(v). In the simplest case where this partitions the vertices into suitable classes for drawing the algorithm then is optimal. In the worst case, the conditions must be applied to pairs of vertices, then the classification procedure reapplied; the algorithm is then O ( v 2).

REFERENCES 1. Bernard, M.A., The Automated Design and Drawing of Graphs, M.Phil Thesis, The University of the West Indies. Trinidad, 1980

2. Read, R.C., The Coding of Various Kinds of Unlabelled Trees, Graph Theory and Computing (Ed. R.C.Read), Academic Press, 1972 3. Parris.R. and Read, R.C., A Coding Procedure for Graphs, Scientific Report UWI/CC10 (AFOSR Grant 1026-66), The University of the West Indies, Jamaica, 1970