Study of Proper Hierarchical Graphs on a Grid

Hierarchical planar graph embedding (sometimes called level planar graphs) is widely recognized as a very important task in diverse fields of research and development. Given a proper hierarchical planar graph, we want to find a geometric position of every vertex (layout) in a straight-line grid drawing without any edge-intersection. An additional objective is to minimize the area of the rectangular grid in which G is drawn with more aesthetic embedding. In this paper we propose several ideas to find an embedding of G in a rectangular grid with area, ( -1) × (k-1), where is the number of vertices in the longest level and k is the number of levels in G.)


INTRODUCTION
The drawing of directed acyclic graphs (DAG) is widely recognized as a very important task in diverse fields of research and development.Examples include VLSI Design and plant layout [1], graphical user interfaces [2], software and information engineering, project management, visual languages [3], subroutine-call graphs, Interpretative Structural Modeling [4], organization charts, hierarchical relationships, system theory and other research fields.The usefulness of a graph depends on its layout that should be readable, understandable and easy to remember.A fundamental issue in Automatic Graph Drawing is to display hierarchical network structures, as they appear in many applications.The network is transformed into a directed acyclic graph (DAG) that has to be drawn with edges that are strictly monotone with respect to the vertical direction.Many applications imply a partition of the vertices into levels that have to be visualized by placing the vertices that belonging to the same level on a horizontal line.The corresponding graphs are called level graphs, and the drawing of the networks that correspond to this category of graphs means the drawing of level graphs (see [5]).
The use of integer coordinates in embedding a graph on the grid has many advantages such as speed, accuracy, and it guarantees automatically that the resultant picture has fairly good properties.A straight line drawing is a grid drawing if each vertex is at a grid point, and the edges are represented as straight-line segments between their endpoints without any edge-intersection.See Figure 1.
Usually, we use one of some aesthetic criteria (such as drawing area minimization, minimizing the number of edge crossings, symmetry, bends minimization or distributing the vertices uniformly) in order to make the layout of a graph readable and understandable [6], [7].Reducing the number of edge crossings or distributing the vertices uniformly have been proposed and evaluating goodness of drawing based on these criteria has been reported [8], [9], [10].Many works have been published area requirements for drawing hierarchically planar graphs [6], [7], [8], [11].In [6] introduced genetic algorithms (GAs) with the problem of drawing of level planar graph or hierarchical planar graph, and explored the potential use of GAs to solve this particular problem.They showed that the GAs can help find a layout of levels and hierarchical planar graphs without any crossing edges.
Lin and P. Eades [12] show that for each hierarchically planar straight-line drawing of G, where each pair of vertices in the same layer are at least distance 1 apart, has width at least where n is the number of vertices in the graph.J.
Abello [13] highlighted the main tasks behind the computation of hierarchical graph maps and provided several examples.The techniques have been used experimentally in the navigation of very large graphs.
In this paper, we are concerned with drawing of level planar G in the plane such that the vertices of G are represented as grid points, and the edges are represented as straight-line segments between their endpoints without any edgeintersection.An additional objective is to minimize the area of www.ijacsa.thesai.org the rectangular grid in which G is drawn.We introduce new algorithms these find an embedding of G.These new algorithms gives level planar drawing in a rectangular grid with area (  -1)×(k-1), where  is the number of vertices in the longest level.This paper is organized as follows.After summarizing the necessary preliminaries in the next section.In the first algorithm, SimpleProperLevel, we explain proper placement for the vertices of a level graph with minimum area in the third section.In the fourth section we explain the second algorithm, FixedDistance, redistribute of the vertices with fixed distance between any two consecutive vertices in the same level on the grid drawing.In section five, DegreeDistance algorithm, redistribute of the vertices on the grid according to its degrees.Finally, Conclusion and references are presented.

II. PRELIMINARIES
Given a directed acyclic graph ) , , ( has a leveling with k being the largest integer such that k V is not empty, G is said to be a k-level graph.For a k-level graph G, we sometimes write ) ; ,..., , ( A drawing of G in the plane is a level drawing if the vertices of every j V , 1  j k, are placed on a horizontal line } , and every edge , is drawn as a monotone decreasing curve between the lines i l and j l .A level drawing of G is called level planar if no two edges cross except at common endpoints.A level graph is level planar if it has a level planar drawing.A level graph ) , , ( is said to be proper, if every edge connects only vertices belonging to consecutive levels.Usually, level graph G has sinks and sources placed on various levels of the graph.For example, Figure 2.a, taken from [14], [15], shows a level graph.Hierarchy is a level graph such that all sources belong to the first level 1  V of the graph.As a consequence, we consider only hierarchies with  In Figure 3 we give four different embeddings of the same level graph in a rectangular grid with area 7×4.From Figure 3, it is so easy to observe that for a level graph, there are several embeddings; each one differs in view from the others.The difference in view between several embeddings of the same graph is due to the differences in the distances between each two consecutive levels in the graph, and to the differences in the distances between each two consecutive vertices in each level.According to a certain application, an embedding of a level graph may be more convenient than the other ones, and the convenient embedding may be inconvenient to another application.
Jünger, Liepert and Mutzel [16] have given a level planarity test algorithm of G in linear time.Using PQ-tree data structure, Jünger and Liepert [5] have given an algorithm that embeds a level planar graph in linear time, that algorithm was based on a level planarity test in [16].
By P(v) we will denote the current position of vertex v in the grid, i.e., P(v):=(x(v),y(v)).By P(u,v) we denote the embedding of edge e(u,v), that is, the line segment that connects P(u) with P(v).The following symbols will be used in this paper: is the vertical distance between any two consecutive levels in the graph.
is the horizontal distance between any two consecutive vertices in the level V i .D is the horizontal distance between any two consecutive vertices in the longest level.l I is the number of vertices that belong to the level V i .


is the number of vertices in the longest level.K is the number of levels in given level graph G. i  is the total degree of the vertices in the level j  is the degree of the vertex j in the level H,W are the height and the width of the used rectangular grid, respectively.E e  www.ijacsa.thesai.orgIn Figure 4 an example to illustrate some of above symbols of given proper level graph, with four levels.The longest level is V 3 with five vertices.
be a given proper level graph with n vertices.An embedding of a level graph can be aesthetic if we redraw the graph by making the distances between each two consecutive vertices, d i are equal in the same level, and for every level the distances between each two consecutive levels, h i are equal also.Now we describe the embedding strategy of the first algorithm.Simply, we put d i =1 and h i =1 for all levels, but the positions of vertices for each level distributed about the middle point of the width W at this level.The value [W / 2] means that, the integer part of real value W/2.It is clear that, the high of the used rectangular grid, ) algorithm can now be described as follows: Output: An embedding of the level graph G on grid drawing.Begin Let  is the number of vertices in the longest level.Now we compute the x-and y-coordinate

 
, as follows: End { Now we have a drawing of G i .}End Output the drawing of G. End.
Lemma 1: For each 1< i  k, when we add i V , then after applying the equations ( 1)&( 2), all neighbors of i V are visible, that the edges between i V and and ki of any vertex in the consecutive level i V .So, all neighbors of  2) according to its order in i V , so the edges between i V and The lemma above implies immediately that adding i V ,1< i  k, satisfies the conditions of drawing level graph, as stated in the corollary below.

grid, where  is the number of vertices in the longest level in G.
Proof: It is clear that, the height H of drawing grid, H = h 1 + h 2 +…+ h k-1 , since h i =1 as minimum value for all levels, then H =k-1. Also, from equation (1), H= y (v) = k-1 , for any 1 V v  .The width is equal to x-coordinate value of vertex number  in the longest level.Replace l i by  in equation (2), Hence, the area used for drawing any given proper level graph is a function of the number of levels and the number of vertices in the longest level.Hence, the proof is completed.

given, then SimpleProperLevel algorithm can be computed in linear-time.
Proof: We embed one level every one-time run of outerloop in the algorithm.Since k is the number of levels in given level graph G, outer-loop is run in k-times.In inner-loop, every vertex in a level will be visited once.But l i is number of vertices in a level i V .Hence the algorithm can be computed in times.Hence, the proof is completed.
Notice: We can get more aesthetic embedding of any level graph G by replacing the equation (2) by the following equation: We can see the difference between using SimpleProper-Level algorithm with the two equations (1&2) and with the two equations (1&3), by embedding the given graph in figure 4 be a given level planar graph with n vertices.The values of the distance d i between each two consecutive vertices in a level are computed by dividing the number of vertices in the longest level  by the number of vertices in that level i.Its means that d i = [  / l i ].Since  is greater than or equal to l i , then we ensure that d i is at least one grid unit .Note that the distance d i between each two consecutive vertices is constant value through level i.In order to determine P(v j ) , j=1,2,…,l i , in the proposed algorithm , when adding a vertex v j , we determine its location in the grid by placing v j such that P(v j )=(x, y), where: In the equation ( 4), we will locate the leftmost and rightmost vertices in the longest level to the left and right boundaries of the grid respectively.And for the other levels we keep to equal distances, one between the left boundary and the leftmost vertex and the other one between the right boundary and the rightmost vertex using the term [(  / 2 -(l i -1)*d i / 2].
The output of this algorithm is an embedding of the level graph G on grid drawing with constant distance d i and more visible distribution of vertices than the SimpleProperLevel algorithm.The complete ConstantDistance( ) algorithm can now be described as follows: Output: An embedding of G on grid drawing.
Begin For i=1 to k Begin Output the drawing of G. End.
Here we give an example to compare the above algorithms.In this example, we embed a given level graph with seventeen vertex (n=17), sixteen edge (m=16 ), five levels (k=5), and 5 vertices in the longest level which is the level number 2 or 4, (  =5).We embed it using SimpleProperLevel algorithm, where the distance between any two vertices is one unit, see Figure Proof: It is clear that, the high of drawing grid, H = y(v The width is equal to x-coordinate value of vertex  in the longest level.Since d i = [  / l i ], put l i =  in equation ( 4), then we obtain that Proof: Using ConstantDistance algorithm, Scince W=  -1 as minimum width in grid, then we can take d i = [(W+1)/l i ] for W   -1 and the equation (4) become x(v j )= [(W+1)/ 2 -(l i -1)*d i / 2] + ( j -1)*d i Applying the equation (4), we ensure that all vertices are embeds in the width W. On the other hand, the hight is arbitrary positive integer value between any two levels in level graph G.The proof is completed.www.ijacsa.thesai.org6 in four different areas.It is so easy to observe that for a level graph, there are several embeddings, each one differs in view from the others and the convenient embedding may be inconvenient to another application.

V. DISTRIBUTION ON GRID USING DEGREES OF VERTICES
In this section we distribute the vertices on the grid according to its degree.So, the distance between each two consecutive vertices is not fixed value in the same level i.Let i  is the total degrees of the vertices in the level i, and j  is the degree of the vertex j.We calculate the weight j  of each vertex in any level i, as the average value of the vertex v j degree and the degress of its left and right vertices, In this case, when adding a vertex v j , we determine its location in the grid by placing v j such that P(v j )=(x, y), where: The complete DegreeDistance( ) , , ( ) algorithm can now be described as follows: Output: An embedding of the level graph G on grid drawing.

Begin
For i=1 to k Begin For j=1 to l i Begin Output the drawing of G. End.Consequently, from above algorithm, we obtain the following theorem: , which needs a rectangular grid with area at least (  -1)×(k-1) grid.Since we embed one level every one-time run of outer-loop in the algorithm.And k is the number of levels in given level graph G, outer-loop is run in k-times.In inner-loop, every vertex in a level will be visited once in a level i V .Hence the algorithm www.ijacsa.thesai.orgcan be computed in linear-time times.Hence, the proof is completed.Here we give an example to compare the above three algorithms.In this example, we embed a given level graph with n=45, m=64, six levels (k=6), and twelve vertices in the longest level which is the level number 4, (  =12).In Figure 8.(a) using SimpleProper-Level algorithm.The output of this drawing has the property that the distance between any two vertices for all vertices is constant and equal to one grid unit.Figure 8.(b) using ConstantDistance algorithm.This drawing has the property that the distance between any two vertices in the same level are constant and is equal to one or more one grid unit.In Figure 8.(c) using DegreeDistance algorithm.The output of this drawing depends on the degree of the vertex and its neighbors for all vertices.

VI. CONCLUSION
In this paper, we introduced new three algorithms for embedding a proper level graph on grid with minimum width.These algorithms keep a proper placement for the nodes that belonging to the same level for each level in the graph.An additional objective is to minimize the area of the rectangular grid in which G is drawn with more aesthetic embedding, that is clearly in the second algorithm.These algorithms run in time ) (n O where n is the number of nodes in the graph.It is possible to draw a given level graph within the area W×H.One of the goals of this area of research should be to extend this further, and to determine an optimal width-height tradeoff for grid drawings.Then for any feasible pair (W, H) we could apply a method that gives best drawings on grids of size (W, H).In this paper we introduced several ideas to find an embedding of G in a rectangular grid with area, (  -1)×(k-1), where  is the number of vertices in the longest level and k is the number of levels in G.

Figure 1 .
Figure 1.Straight line drawing of level planar graph

Figure 2 .
Figure 2. Examples of proper level graphs, sources are drawn black

Figure 2 .
b shows a hierarchy.

Figure 3 .
Figure 3. Four different embeddings of the same level graph in area 7x4

Figure 4 .
Figure 4. Example of proper level graph k=4.III.EMBEDDING OF GRAPH IN MINIMUM AREA Let ) ; ,..., , ( 2 1 visible.Since the vertices in the levels are ordered, The x-coordinate values of) . It www.ijacsa.thesai.org is clear that the embedding of Figure (5.b) is more aesthetic than the one given in Figure (5.a).

Figure 7 .
Figure 7. Embedding of the same level graph in Figure 6 in 4 different areas.

Figure 7
Figure 7 illustrate lemma 2, embedding of the same level graph in Figure6in four different areas.It is so easy to observe that for a level graph, there are several embeddings, each one differs in view from the others and the convenient embedding may be inconvenient to another application.

.
Note that if there is not any left or right vertex consider that the degree of left or right equal to zero.Hence, we can calculate the distance d ij between the vertex v j-1 and v j as a function of total degree i  of the level and its weight j  , so we can putd ij = [  * j  / i  ].To overcome confidingness, if d ij = 0 , j >1 , we consider d ij = 1.

Theorem 5 : 1 V
DegreeDistance algorithm constructs a straightline embedding of proper level graph) rectangular grid with area at least (  -1) × (k-1) grid and it can be computed in linear-time.Proof: It is clear that, the high of drawing grid, H = y(v  ) = k-1.At least the width is equal to x-coordinate value of vertex  in the longest level.Since d ij 1, From equation (5), we obtain that W =  d  j   -1.Then in this case,

Figure 8 .
Figure 8. Three different embeddings of the same graph in minimum area.
given , then ConstantDistance algorithm can be computed in linear-time.