A circular layout algorithm for attributed hierarchical graphs with ports

Information visualization based on graph models is a key component of support tools for many applications in science and engineering. The Visual Graph system is intended for visualization of big amounts of complex information on the basis of attributed hierarchical graph models. In this paper, a circular layout algorithm for attributed hierarchical graphs with ports and its effective implementation in the Visual Graph system are presented.


Introduction
Graphs are widely used to describe and structure information in subject areas, where it is necessary to model connections between objects. Graph visualization techniques which embed graphs onto a two or three-dimensional surface where vertices are represented by points, boxes or ellipses and arcs are represented by curves connecting them visualization, have many areas of application [1,4,6].
For visual analysis of data and connections between them, it is required to build graphical representations vary greatly according to the application domain and taking into account a variety of so-called aesthetic criteria. For example, planarity and the display of symmetries are often highly desirable in graph visualization for many applications. In general, in order to improve the readability of graph drawings, it is important to keep the number of arc-arc crossings low as possible. Also, to avoid wasting of space on screen (or page), it is important to keep area of the graph drawing as small as possible. Trying to satisfy all criteria is generally infeasible if not impossible, as they are inherently conflicting, and some trade-offs are usually used [1].
In some application areas the organization of information is too complex to be modeled by classical graphs, and some more powerful graph formalisms and new methods for hierarchical visualization have been introduced [2,3,4,5,10,13]. A practical and general graph formalism called hierarchical graphs and graph models can handle many applications with complex information, and is amenable to graph drawing [5,7,9]. It forms a basis for natural "abstraction" and "reduction" techniques that can be applied by researchers in order to reduce the visual complexity of a large graph. It divides the graph into parts (called fragments) so that all elements of each fragment are similar in some sense and all considered fragments form a hierarchy of nested graph parts. This hierarchy provides a good means of handling size complexity for those applications which are obliged to deal with large amounts of data. The Visual Graph visualization system created at the A.P. Ershov Institute of Informatics Systems SB RAS is based on attributed hierarchical graph models and allows exploring complex structured large data through their visual representations [8].
In many applications, the objects modeled by the vertices of the graph contain disjoint logical locations (so-called ports [14]), through which they (objects) are in the relationship that is modeled by arcs. For example, in program graphs that represent the flow of data in a program, the vertices represent program statements, the ports of the vertices represent the operands of the statements (their arguments and results) and arcs connected ports represent data flow between results and arguments of statements [8].
The readability of the resulting graph image strongly depends on the way its elements (vertices and arcs) are laid on the plane. A circular graph drawing is an embedding of a graph on the plane such that all vertices are placed onto the circumference of a circle and each arc is drawn into the circle usually as a straight line [12], but the problem of producing a circular drawing with a minimum number of arc crossings is NP-Complete [11]. Circular layout finds its application in areas where the objects represented by the graph vertices are of equal priority, and none of them occupies a privileged position. Circular graph layouts are used to visualize ring and stellar network topologies, biological and social networks, and smaller clusters in a large graph. Since these applications deal with big data, the problem of developing a circular layout algorithm for general hierarchical graphs is very relevant, but at present only for clustered graphs being some simple hierarchical graphs without ports a circular layout algorithm has been developed [15].
In this paper an algorithm for circular layout of attributed hierarchical graphs with ports and an extension for the Visual Graph system that implements this algorithm are described. Two heuristics are considered to minimize arc-arc intersections. To solve the arc-to-vertex intersection problem, rounded arc inserts are used.
The rest of the paper is organized as follows: Section 2 considers the attributed hierarchical graphs with ports and their drawings, Section 3 describes our circular layout algorithm for the attributed hierarchical graphs, Section 4 presents the algorithm implementation in the Visual Graph system, and Section 5 concludes the paper and highlights the future research directions.

Attributed hierarchical graphs with ports and their drawings
To better describe the algorithm, we first introduce some notations from [5]. Let G be a graph of some type, e.g. G can be an undirected graph or a directed graph. A graph G is defined by two finite sets V and E, where the elements of V are the vertices of G, and the elements of E are the arcs of G. G is a trivial graph if |V| = 1 and |E| = 0.
A graph C is called a fragment of G, denoted by C G, if C includes only elements (vertices and arcs) of G. A set of fragments F is called a hierarchy of nested fragments of the graph G, if the following two properties hold: (1) F contains the graph G and all vertices V, and (2) C 1 C 2 , C 2 C 1 or C 1  C 2 = for any C 1 , C 2  F.
A hierarchical graph H = (G, T) consists of a graph G and a rooted tree T that represents an immediate inclusion relation between elements of a hierarchy F of nested fragments of G. G is called the underlying graph of H. T is called the inclusion tree of H.
A hierarchical graph H is called a connected one, if each fragment of H is connected graph, and a simple one, if all fragments of H are induced subgraphs of G.
It should be noted that any clustered graph [2] can be considered as a simple hierarchical graph H = (G, T) such that G is an undirected graph and any fragments CF is considered as the set of vertices of C.
Let P be a finite set of ports. A port pP is a special vertex of a hierarchical graph which is attached to a fragment C F and serves to designate the point where the arc enters the anchored fragment C. It is assumed that each arc of the hierarchical graph with ports is an arc between two ports.
Let P(C) be an ordered set of ports of a fragment C and P i (C) be the port of C with number i. An arc u = (P i (w), P j (z)) breaks a fragment C (u is a breaking arc) if C includes an element from the set {w, z} and does not include the other element.
A hierarchical graph H with ports is a structural one if it has no breaking arc. Let u =(P i (w), P j (z)) be a breaking arc of a fragment C. Transformation of removal from H of breaking arc u is defined as replacing in H the arc u =(P i (w), P j (z)) by two arcs (P i (w), Pt(v)) and (P t (v), P j (z)) where P t (C) is a new dummy port added to the fragment C.
H 1 is a structural extension of a hierarchical graph H 2 if H 1 is a structural hierarchical graph which can be constructed from H 2 by iterative application of breaking arc removal transformation. A drawing (or layout) D of a hierarchical graph H is a representation of H in the plane such that the following properties hold.
1. Each port, vertex and fragment of G is represented by a simple closed region (a cycle in our case). The region is defined by its boundary (a simple closed curve in the plane) which divides the plane into two parts: inside face and outside face.
2. For any C 1 , C 2  F the intersection of regions of C 1 and C 2 is empty if and only if C 1  C 2 =, and the region of each fragment C F includes all regions of all fragments nested into it.
3. Any two ports of each fragment C F are represented by two nonintersected regions. The region of each port of C is divided into three nonempty sets of points: points of the inside face of region of C, points of its boundary and points of its outside face.
4. Each arc of H is represented by a simple curve between the drawings of its endpoints (ports). 5. All arcs of any fragment C of H are located inside the region of C.
A drawing D of a hierarchical graph H is a circular one if for any fragment from F all its sons in T (or all fragments C directly nested into it) are placed onto the circumference of a circle.

Circular layout algorithm
Below it is assumed that the input graph is a hierarchical graph H = (G, T) with ports, and the algorithm output is a circular drawing D of a structural extension of H. The algorithm performs of traversing the nesting tree T in depth. At each step of traversing, a certain fragment C being considered as a vertex of T is drawn using the sizes and positions of the fragments directly nested into it. Note that after building an image for a fragment, it is possible to calculate its sizes and use them when drawing a fragment in which it is nested will be performed.
The algorithm of the drawing of a fragment is consists of following three stages. 1. Calculation of the fragment sizes. 2. Ordering fragments relative to each other. 3. Layout of the arcs.
To construct a circular image, it is proposed to divide the algorithm into three passes through all levels of the hierarchy represented by T. This is due to the fact that the calculation of the fragment sizes and the laying of the arcs must be done in a different order since the calculation of the sizes should starts with the leaves of the nesting tree T, but the layout of the arcs should starts with its root.

Calculation of the fragment sizes
The size of all trivial fragments (or leaves of T) is already specified at the input to the algorithm. For other fragments, the sizes can be calculated only taking into account the sizes of the fragments lying inside. It follows from this that the first stage should be carried out from a low level of the hierarchy to a high one, since first you need to calculate the sizes of the inner fragments. At this stage, the following three steps should be performed for a given set of fragments.
1. The radius of the circle on which the given set of fragments will be located is calculated. This is possible because the sizes of all given fragments are already known. The minimum radius of a circle that could cover any given fragment is calculated and used.
2. All given fragments are evenly spaced around the circumference of the calculated radius.
3. If the given fragments are internal to a fragment distinct from G, then the size of this fragment is calculated. After that, real (or nondummy) ports, if any, are evenly placed around the circumference of the fragment.
If we consider dummy ports, then an arc must connect with an outside port, because this is a condition for the existence of a dummy port. In the case of real ports, this is not the case; they can only connect to the inner ports of the fragment. Accordingly, it is required to set positions for ports for which there are no external arcs. But defining external relations is a rather expensive operation. Therefore, the positions are set for all ports, but later (at the stage of laying the arcs) some ports can be interchanged.

Ordering fragments relative to each other
The task of this stage is to find such an order of the fragments on the circle that the number of intersections of arcs is minimal. It should be noted that the number of intersections of arcs in the circular graph drawing does not depend on the final coordinates of the fragments, but depends only on their relative position on the circle (their ordinal number). Thus, this problem is combinatorial, not geometric. However, this problem is NP-complete [11]. Therefore, below we will give two heuristics that find the order of the fragments in polynomial time, but do not guarantee the best result on any graph. Let's designate them as permutation and grouping heuristics, based on the peculiarities of each f them. o with C is selected.
umber of links between them and placed so that the he number of arcs lying on the bou g fragments to mi consists of the following four steps.
or each considered pair. The last pair under consideration consists of the last and nts in the considered pair leads to a dec ns as much as possible. It is suitable for use on small graphs where the lack of speed is not noticeable.
The grouping heuristic is based on the assumption that the number of intersections between arcs will decrease if the most connected fragments are placed side by side. This location of the fragments leads to a decrease in the number of arcs lying close to the centre of the circle. As a rule such arcs cause a large number of intersections, because their length is close to th en drawing. The grouping heuristic consi 1. Let S be a set of all given fragments.
2. Let C be the most connected fragment from S. 3. A group of all given fragments directly connected 4. All fragments of the group are removed from S. 5. The fragments of the group are sorted by the n least connected fragments are located "outside". 6. If the set S is not empty, then the algorithm continues from step 2.
It should be noted that this approach leads to an increase in t ndary of the drawing circle and has a quadratic time complexity. The algorithm of the permutation heuristic uses cyclic permutation of neighbourin nimize intersections. The permutation heuristic 1. Let S be a sequence of all given fragments. 2. The algorithm considers step by step all adjacent pairs of fragments from S beginning from (C 1 , C 2 ) and reforms step 3 f first elements of S.  If the arc is associated with a port at a lower level, then its position is also determined. The layout process goes from a high level of hierarchy to a low one, because to lay arcs, it is needed to know the coordinates of the ports, which are determined on the base of the arcs of a higher level. At this stage, the the s when the arc leaves the circle. The "end of arc" point is calculated and added to the end om which the arc originates has a corresponding port, then it is assigned the "st ment to which the arc arrives has a corresponding port, then it is assigned the following six steps should be performed. 1. There is an empty list at the input, to which control points will be added. 2. The point "start of the arc" is calculated and added to the beginning of the list. 3. If there is a point at which the arc approaches to a non-incident fragment on a given distance, n points projecting the arc onto a circle of some radius centred at this fragment are added to the list.

Conclusion
The paper describes the created circular layout algorithm that draws attributed hierarchical graphs with ports in quadratic time and its effective implementation in the Visual Graph system. The algorithm takes into account the criterion for minimizing intersections and uses rounded arc inserts for solving the arc-to-vertex intersection problem. Its ability to draw lications and is new for circular layout algorithms.
In the future, the algorithm can be improved in the following directions. First, we plan to improve sorting heuristic. For example, it is possible to make by adding sorting for adjacent levels or by improving intersection minimization. Second, we plan to take into account and preserve the initial order of fragment ports. We plan also to reduce the area of the drawing graph due to the economical distribution of fragments of hierarchical graphs on circ