Force-Directed Layout of Order Diagrams using Dimensional Reduction
FForce-Directed Layout of Order Diagrams usingDimensional Reduction
Dominik Dürrschnabel , − − − andGerd Stumme , − − − Knowledge & Data Engineering Group, University of Kassel, Germany Interdisciplinary Research Center for Information System DesignUniversity of Kassel, Germany {duerrschnabel,stumme}@cs.uni-kassel.de
Abstract.
Order diagrams allow human analysts to understand and an-alyze structural properties of ordered data. While an experienced expertcan create easily readable order diagrams, the automatic generation ofthose remains a hard task. In this work, we adapt force-directed ap-proaches, which are known to generate aesthetically-pleasing drawingsof graphs, to the realm of order diagrams. Our algorithm
ReDraw therebyembeds the order in a high dimension and then iteratively reduces thedimension until a two-dimensional drawing is achieved. To improve aes-thetics, this reduction is equipped with two force-directed steps whereone optimizes on distances of nodes and the other on distances of linesin order to satisfy a set of a priori fixed conditions. By respecting aninvariant about the vertical position of the elements in each step of ouralgorithm we ensure that the resulting drawings satisfy all necessaryproperties of order diagrams. Finally, we present the results of a userstudy to demonstrate that our algorithm outperforms comparable ap-proaches on drawings of lattices with a high degree of distributivity.
Keywords:
Ordered Sets · Order Diagram Drawing · Lattice Drawing· Force-Directed Algorithms · Dimensional Reduction · Graph Drawing
Order diagrams , also called line diagrams , Hasse diagrams (or simply diagrams )are a graphical tool to represent ordered sets. In the context of ordinal dataanalysis , i.e., data analysis investigating ordered sets, they provide a way for ahuman reader to explore and analyze complex connections. Every element of theordered set is thereby visualized by a dot and two elements are connected by astraight line if one is lesser than the other and there is no element “in between”.The general structure of such an order diagram is therefore fixed by theseconditions. Nonetheless, finding good coordinates for the dots representing theelements such that the drawing is perceived as “readable” by humans is not atrivial task. An experienced expert with enough practice can create such a draw-ing; however, this is a time-consuming and thus uneconomical task and therefore a r X i v : . [ c s . C G ] F e b Dominik Dürrschnabel and Gerd Stumme rather uncommon. Still, the availability of such visualizations of order diagrams isan integral requirement for developing ordinal data science and semi-automateddata exploration into a mature utensil; thus, making the automatic generation ofsuch order diagrams an important problem. An example of a research field thatis especially dependent on the availability of such diagrams is Formal ConceptAnalysis, a field that orders concepts derived from binary datasets in lattices.The generated drawings have to satisfy a set of hard constraints in order toguarantee that the drawing accurately represents the ordered set. First of all, forcomparable elements the greater element dot has to have a larger y -coordinatethen the lesser element dot. Secondly, no two element dots are allowed to bepositioned on the same coordinates. Finally, element dots are not allowed totouch non-adjacent lines. Beside those hard criteria, there is a set of commonlyaccepted soft criteria that are generally considered to make a drawing more read-able, as noted in [16]. Those include maximizing the distances between elementdots and lines, minimizing the number of crossing lines, maximizing the angles ofcrossing lines, minimizing the number of different edge directions or organizingthe nodes in a limited number of layers. While it is not obvious how to developan algorithm that balances the soft criteria and simultaneously guarantees thatthe hard criteria are satisfied, such an algorithm might not even yield readableresults as prior works such as [3] suggests. Furthermore, not every human readermight perceive the same aspects of an order diagram as “readable”; conversely, itseems likely that every human perceives different aspects of a good drawing asimportant. It is thus almost impossible to come up with a good fitness functionfor readable graphs. Those reasons combined make the automatic generation ofreadable graph drawing - and even their evaluation - a surprisingly hard task.There are some algorithms today that can produce readable drawings tosome extent; however, none of them is able to compete with the drawings thatare manually drawn by an expert. In this paper we address this problem byproposing our new algorithm ReDraw that adapts the force-directed approachof graph drawing to the realm of order diagram drawing. Thereby, a physicalsimulation is performed in order to optimize a drawing by moving it to a stateof minimal stress. Thus, the algorithm proposed in this paper provides a wayto compute sufficiently readable drawings of order diagrams. We compare ourapproach to prior algorithms and show that our drawings are more readableunder certain conditions or benefits from lesser computational costs. We providethe source code so that other researchers do own experiments and extend it. Order diagram drawing can be considered to be a special version of the graphdrawing problem, where a graph is given as a set of vertices and a set of edges anda readable drawing of this graph is desired. Thereby, each vertex is once againrepresented by a dot and two adjacent vertices are connected by a straight line. https://github.com/domduerr/redraw orce-Directed Layout of Order Diagrams using Dimensional Reduction 3 The graph drawing problem suffers from a lot of the same challenges as orderdiagram drawing and thus a lot of algorithms that were developed for graphdrawing can be adapted for diagram drawing. For a graph it can be checked inlinear time whether it is planar [11]), i.e., whether it has a drawing that has nocrossing edges. In this case a drawing only consisting of straight lines withoutbends or curves can always be computed [12, Sect. 4.2 & 4.3] and should thusbe preferred. For a directed graph with a unique maximum and minimum, likefor example a lattice, it can be checked in linear time whether an upward planardrawing exists. Then such a drawing can be computed in linear time [2, Sect. 6].The work [2, Sect. 3.2] provides an algorithm to compute straight-line drawingsfor “serial parallel graphs”, which is a special family of planar, acyclic graphs. Assymmetries are often preferred by readers, the algorithm was extended [10] toreflect them in the drawings based on the automorphishm group of the graph.However, lattices that are derived from real world data using methods like FormalConcept Analysis rarely satisfy the planarity property [1]. The work of Sugiyamaet al. [14], usually referred to as Sugiyama’s framework, from 1981 introduces analgorithm to compute layered drawings of directed acyclic graphs and can thusbe used for drawing order diagram. Force-directed algorithms were introducedin [5] and further refined in [7]. They are a class of graph drawing algorithmsthat are inspired by physical simulations of a system consisting of springs.The most successful approaches for order diagram drawing are a work ofSugiyama et al. [14] which is usually referred to as Sugiyama’s framework and awork of Freese [6]. Those algorithms both use the structure of the ordered set todecide on the height of the element dots; however, the approach choosing the hor-izontal coordinates of a vertex dot differ significantly. While Sugiyama’s frame-work minimizes the number of crossing lines between different vertical layers,Freese’s layout adapts a force-directed algorithm to compute a three-dimensionaldrawing of the ordered set. DimDraw [4] on the other hand is not an adaptedgraph drawing algorithm, but tries to emphasize the dimensional structure thatis encapsulated in the ordered set itself. Even though this approach is shown tooutperform Freese’s and Sugiyama’s approach in [4], it is not feasible for largerordered sets because of its exponential nature. in [4] proposes a method to draworder diagrams based on structural properties of the ordered set. In doing so,two maximal differing linear extensions of the ordered set are computed. Thework in [8] emphasizes additive order diagrams of lattices. Another force-directedapproach that is based on minimizing a “conflict distance” is suggested in [17].In this work we propose the force-directed graph drawing algorithm
ReDraw that, similarly to Freese’s approach, operates not only in two but in higherdimensions. Compared to Freese’s layout, our algorithm however starts in anarbitrarily high dimension and improves it then by reducing the number of di-mensions in an iterative process. Thus, it minimizes the probability to stop thealgorithm early with a less pleasing drawing. Furthermore, our approach gets ridof the ranking function to determinate the vertical position of the elements andinstead uses the force-directed approach for the vertical position of dots as well.We achieve this by defining a vertical invariant which is respected in each step of
Dominik Dürrschnabel and Gerd Stumme the algorithm. This invariant guarantees that the resulting drawing will respectthe hard condition of placing greater elements higher than lesser elements.
In this section we recall fundamentals and lay the foundations to understand de-sign choices of our algorithm. This includes recalling mathematical notation anddefinitions as well as introducing the concept of force-directed graph drawing.
We start by recalling some standard notations that are used throughout thiswork. An ordered set is a pair ( X, ≤ ) with ≤ ⊆ ( X × X ) that is reflexive ( ( a, a ) ∈≤ for all a ∈ X ), antisymmetric (if ( a, b ) ∈ ≤ and ( b, a ) ∈ ≤ , then a = b ) andtransitive (if ( a, b ) ∈ ≤ and ( b, c ) ∈ ≤ , then ( a, c ) ∈ ≤ ). The notation ( a, b ) ∈ ≤ is used interchangeable with a ≤ b and b ≥ a . We call a pair of elements a, b ∈ X comparable if a ≤ b or b ≤ a , otherwise we call them incomparable . A subset of X where all elements are pairwise comparable is called a chain . An element a iscalled strictly less than an element b if a ≤ b and a (cid:54) = b and is denoted by a < b ,the element b is then called strictly greater than a . For an ordered set ( X, ≤ ) ,the associated covering relation ≺ ⊆ < is given by all pairs ( a, c ) with a < c forwhich no element b with a < b < c exists. A graph is a pair ( V, E ) with E ⊆ (cid:0) V (cid:1) .The set V is called the set of vertices and the set E is called the set of edges ,two vertices a and b are called adjacent if { a, b } ∈ E .From here out we give some notations in a way that is not necessarily stan-dard but will be used throughout our work. A d -dimensional order diagram or drawing of an ordered set ( X, ≤ ) is denoted by ( (cid:126)p a ) a ∈ X ⊆ R d whereby (cid:126)p a = ( x a, , . . . , x a,d − , y a ) for each a ∈ X and for all a ≺ b it holds that y a < y b .Similarly, a d -dimensional graph drawing of a graph ( V, E ) is denoted by ( (cid:126)p a ) a ∈ V with (cid:126)p a = ( x a, , . . . , x a,d − , y a ) for each a ∈ V . If the dimension of a order dia-gram or a graph drawing is not qualified, the two-dimensional case is assumed.In this case an order diagram can be depicted in the plane by visualizing theelements as a dot or nodes and connecting element pairs in the covering rela-tion by a straight line. In the case of a graph, vertices are depicted by a dotand adjacent vertices are connected by a straight line. We call y a the verticalcomponent and x a, , . . . , x a,d − the horizontal components of of (cid:126)p a and denote ( (cid:126)p a ) x = ( x a, , . . . , x a,d − , . The forces operating on the vertical component arecalled the vertical force and the forces operating on the horizontal componentsthe horizontal forces . The Euclidean distance between the representation of a and b is denoted by d ( (cid:126)p a , (cid:126)p b ) = | (cid:126)v a − (cid:126)v b | , while the distance between the vertical com-ponents is denoted by d y ( (cid:126)p a , (cid:126)p b ) and the distance in the horizontal components isdenoted by d x ( (cid:126)p a , (cid:126)p b ) = d (( (cid:126)p a ) x , ( (cid:126)p b ) x ) . The unit vector from (cid:126)p a to (cid:126)p b is denotedby (cid:126)u ( (cid:126)p a , (cid:126)p b ) , the unit vector operating in the horizontal dimensions is denoted by (cid:126)u x ( (cid:126)p a , (cid:126)p b ) . Finally, the cosine-distance between two vector pairs ( (cid:126)a,(cid:126)b ) and ( (cid:126)c, (cid:126)d ) with (cid:126)a,(cid:126)b, (cid:126)c, (cid:126)d ∈ R d is given by d cos (( (cid:126)a, b ) , ( (cid:126)c, (cid:126)d )) := 1 − (cid:80) di =1 ( b i − a i ) · ( d i − c i ) d ( a,b ) · d ( c,d ) . orce-Directed Layout of Order Diagrams using Dimensional Reduction 5 The general idea of force-directed algorithms is to represent the graph asa physical model consisting of steel rings each representing a vertex. For everypair of adjacent vertices, their respective rings are connected by identical springs.Using a physical simulation, this system is then moved into a state of minimalstress, which can in turn be used as the drawing. Many modifications to thisgeneral approach, that are not necessarily based on springs, were proposed inorder to encourage additional conditions in the resulting drawings.The idea of force-directed algorithms was first suggested by Eades [5]. Hisalgorithmic realization of this principle is done using an iterative approach wherein each step of the simulation the forces that operate on each vertex are computedand summed up (cf. Algorithm 1). Based on the sum of the forces operating oneach vertex, they are then moved. This is repeated for either a limited number ofrounds or until there is no stress left in the physical model. While a system con-sisting of realistic springs would result in linear forces between the vertices, Eadesclaims that those are performing poorly and thus introduces an artificial springforce. This force operates on each vertex a for adjacent pairs { a, b } ∈ E and isgiven as f spring ( (cid:126)p a , (cid:126)p b ) = − c spring · log (cid:16) d ( (cid:126)p a ,(cid:126)p b ) l (cid:17) · (cid:126)u ( (cid:126)p a , (cid:126)p b ) , whereby c spring is thespring constant and l is the equilibrium length of the spring. The spring forcerepels two vertices if they are closer then this optimal distance l while it operatesas an attracting force if two vertices have a distance greater then l , see Figure 1.To enforce that non-connected vertices are not placed too close to each other, headditionally introduces the repelling force that operates between non-adjacentvertex pairs as f rep ( (cid:126)p a , (cid:126)p b ) = c rep d ( (cid:126)p a ,(cid:126)p b ) · (cid:126)u ( (cid:126)p a , (cid:126)p b ) . The value for c rep is once againconstant. In a realistic system, even a slightest movement of a vertex changes theforces that are applied to its respective ring. To depict this realistically a dampingfactor δ is introduced in order to approximate the realistic system. The smallerthis damping factor is chosen, the closer the system is to a real physical system.However, a smaller damping factor results in higher computational costs. In someinstances this damping factor is replaced by a cooling function δ ( t ) to guaranteeconvergence. The physical simulation stops if the total stress of the system falls Algorithm 1
Force-Directed Algorithm by Eades
Input:
Graph: ( V, E ) Constants: K ∈ N , ε > , δ > Initial drawing: p = ( (cid:126)p a ) a ∈ V ⊆ R Output:
Drawing: p = ( (cid:126)p a ) a ∈ V ⊆ R t = 1 while t < K and max a ∈ V (cid:107) F a ( t ) (cid:107) > ε : for a ∈ V : F a ( t ) := (cid:80) { a,b }(cid:54)∈ E f rep ( (cid:126)p a , (cid:126)p b ) + (cid:80) { a,b }∈ E f spring ( (cid:126)p a , (cid:126)p b ) for a ∈ V : (cid:126)p a := (cid:126)p a + δ · F a ( t ) t = t + 1 Dominik Dürrschnabel and Gerd Stumme
Fig. 1: The forces forgraphs as introduced byEades in 1984. The f spring force operates betweenadjacent vertices and hasan equilibrium at l , theforce f rep is always a re-pelling force and operateson non-adjacent pairs. Fig. 2: Horizontal forcesfor drawing order di-agrams introduced byFreese in 2004. The force f attr operates betweencomparable pairs, theforce f rep between incom-parable pairs. There is novertical force. Fig. 3: Our forces fordrawing order diagrams. f vert operates verticallybetween node pairs inthe covering relation, theforce f attr between com-parable pairs and theforce f rep between incom-parable pairs.below a constant ε . Building on this approach, a modification is proposed in thework of Fruchterman and Reingold [7] from 1991. In their algorithm, the force f attr ( (cid:126)p a , (cid:126)p b ) = − d ( (cid:126)p a ,(cid:126)p b ) l · (cid:126)u ( (cid:126)p a , (cid:126)p b ) is operating between every pair of connectedvertices. Compared to the spring-force in Eades’ approach, this force is alwaysan attracting force. Additionally the force f rep ( (cid:126)p a , (cid:126)p b ) = l d ( (cid:126)p a ,(cid:126)p b ) · (cid:126)u ( (cid:126)p a , (cid:126)p b ) repelsevery vertex pair. Thus, the resulting force that is operating on adjacent ver-tices is given by f spring ( (cid:126)p a , (cid:126)p b ) = f attr ( (cid:126)p a , (cid:126)p b ) + f rep ( (cid:126)p a , (cid:126)p b ) and has once again itsequilibrium at length l . These forces are commonly considered to achieve betterdrawings than Eades’ approach and are thus usually preferred.While the graph drawing algorithms described above lead to sufficient re-sults for undirected graphs, they are not suited for order diagram drawings asthey do not take the direction of an edge into consideration. Therefore, they willnot satisfy the hard condition that greater elements have a higher y -coordinate.Freese [6] thus proposed an algorithm for lattice drawing that operates in threedimensions, where the ranking function rank ( a ) = height ( a ) − depth ( a ) fixes thevertical component. The function height ( a ) thereby evaluates to the length ofthe longest chain between a and the minimal element and the function depth ( a ) to the length of the longest chain to the maximal element. While this rankingfunction guarantees that lesser elements are always positioned below greater ele-ments, the horizontal coordinates are computed using a force-directed approach.Freese introduces an attracting force between comparable elements that is givenby f attr ( (cid:126)p a , (cid:126)p b ) = − c attr · d x ( (cid:126)p a , (cid:126)p b ) · (cid:126)u x ( (cid:126)p a , (cid:126)p b ) , and a repelling force that is givenby f rep ( (cid:126)p a , (cid:126)p b ) = c rep · d x ( (cid:126)p a ,(cid:126)p b ) | y b − y a | + | x b, − x a, | + | x b, − x a, | · (cid:126)u x ( (cid:126)p a , (cid:126)p b ) operating on in-comparable pairs only, (cf. Figure 2). The values for c attr and c rep are constants.A parallel projection is either done by hand or chosen automatically in order tocompute a two-dimensional depiction of the three-dimensional drawing. orce-Directed Layout of Order Diagrams using Dimensional Reduction 7 Our algorithm
ReDraw uses a force-directed approach similar to the one that isused in Freese’s approach. Compared to Freese’s algorithm, we however do notuse a static ranking function to compute the vertical positions in the drawing.Instead, we use forces which allow us to incorporate additional properties likethe horizontal distance of vertex pairs, into the vertical distance. By respectinga vertical invariant, that we will describe later, the vertical movement of the ver-tices is restricted so that the hard constraint on the y -coordinates of comparablenodes can be always guaranteed. However, the algorithm is thus more likely toget stuck in a local minimum. We address this problem by computing the firstdrawing in a high dimension and then iteratively reducing the dimension of thisdrawing until a two-dimensional drawing is achieved. As additional degrees offreedom allow the drawing to move less restricted in higher dimensions it thusreduces the probability for the system to get stuck in a local minimum.Our algorithm framework (cf. Algorithm 2) consists of three individual al-gorithmic steps that are iteratively repeated. We call one repetition of all threesteps a cycle . In each cycle the algorithm is initialized with the d -dimensionaldrawing and returns a ( d − -dimensional drawing. The first step of the cycle,which we refer to as the node step , improves the d -dimensional drawing by opti-mizing the proximity of nodes in order to achieve a better representation of theordered set. In the second step, which we call the line step , the force-directed ap-proach is applied to improve distances between different lines as well as betweenlines and nodes. The resulting drawing thereby achieves a better satisfaction ofsoft criteria and thus improve the readability for a human reader. Finally, in the reduction step the dimension of the drawing is reduced to ( d − by using aparallel projection into a subspace that preserves the vertical dimension. In thelast (two-dimensional) cycle, the dimension reduction step is omitted.The initial drawing used in the first cycle is randomly generated. The verticalcoordinate of each element dot is given by its position in a randomly chosen linearextension of the ordered set. The horizontal coordinates of each element are setto a random value between -1 and 1. This guarantees that the algorithm does Algorithm 2
ReDraw Algorithm
Input:
Ordered set: O = ( X, ≤ ) Constants: K ∈ N , ε > , δ > ,Initial dimension: d c vert > , c hor > , Output:
Drawing: p = ( (cid:126)p a ) a ∈ V ⊆ R c par > , c ang > , c dist > p = i n i t i a l _ d r a w i n g ( O ) while d ≥ :node_step ( O, p, d, K, ε, δ, c vert , c hor )l i n e _ s t e p (
O, p, d, K, ε, δ, c par , c ang , c dist ) i f d > :dimension_reduction ( O, p, d ) d = d − Dominik Dürrschnabel and Gerd Stumme not start in an unstable local minimum. Every further cycle then uses the outputof the previous cycle as input to further enhance the resulting drawing.Compared to the approach taken by Freese we do not fix the vertical com-ponent by a ranking function. Instead, we recompute the vertical position ofeach element in each step using our force-directed approach. To ensure that theresulting drawing is in fact a drawing of the ordered set we guarantee that inevery step of the algorithm the following property is satisfied:
Definition 1.
Let ( X, ≤ ) be an ordered set with a drawing ( (cid:126)p a ) a ∈ X . The drawing ( (cid:126)p a ) a ∈ X satisfies the vertical constraint , iff. ∀ a, b ∈ X : a < b ⇒ y a < y b . This vertical invariant is preserved in each step of the algorithm and thus thatin the final drawing the comparabilities of the order are correctly depicted.
The first step of the iteration is called the node step , which is used in orderto compute a d -dimensional representation of the ordered set. It thereby em-phasizes the ordinal structure by positioning element pairs in a similar hor-izontal position, if they are comparable. In this step we define three differ-ent forces that operate simultaneously. For each a ≤ b on a the vertical force f vert ( (cid:126)p a , (cid:126)p b ) = (cid:16) , . . . , , − c vert · (cid:16) d x ( (cid:126)p a ,(cid:126)p b ) d y ( (cid:126)p a ,(cid:126)p b ) − (cid:17)(cid:17) operates while on b the force − f vert ( (cid:126)p a , (cid:126)p b ) operates. If two elements have the same horizontal coordinates ithas its equilibrium if the vertical distance is at the constant c vert . Then, if twoelements are closer then this constant it operates repelling and if they are fartheraway the force operates as an attracting force. Thus, the constant c vert is a pa-rameter that can be used to tune the optimal vertical distance . By incorporatingthe horizontal distance into the force, it can be achieved that vertices with a highhorizontal distance will also result in a higher vertical distance. Note, that thisforce only operates on the covering relation instead of all comparable pairs, asOtherwise, chains would be contracted to be positioned close to a single point. Algorithm 3
ReDraw - Node step
Input:
Ordered set: ( X, ≤ ) Constants: K ∈ N , ε > , δ > ,Drawing p = ( (cid:126)p a ) a ∈ X ⊆ R d c vert > , c hor > Output:
Drawing: p = ( (cid:126)p a ) a ∈ X ⊆ R d t = 1 while t < K and max a ∈ X (cid:107) F a ( t ) (cid:107) > ε : for a ∈ X : F a ( t ) := (cid:80) a ≺ b f vert ( (cid:126)p a , (cid:126)p b ) − (cid:80) b ≺ a f vert ( (cid:126)p a , (cid:126)p b )+ (cid:80) a ≤ b f attr ( (cid:126)p a , (cid:126)p b ) + (cid:80) a (cid:54)≤ b f rep ( (cid:126)p a , (cid:126)p b ) for a ∈ X : (cid:126)p a := o v e r s h o o t i n g _ p r o t e c t i o n ( (cid:126)p a + δ · F a ( t ) ) t = t + 1 orce-Directed Layout of Order Diagrams using Dimensional Reduction 9 On the other hand there are two different forces that operate in horizon-tal direction. Similar to Freese’s layout, there is an attracting force betweencomparable and a repelling force between incomparable element pairs; however,the exact forces are different. Between all comparable pairs a and b the force f attr ( (cid:126)p a , (cid:126)p b ) = − min (cid:0) d x ( (cid:126)p a , (cid:126)p b ) , c hor (cid:1) · (cid:126)u x ( (cid:126)p a , (cid:126)p b ) is operating. Note that incontrast to f vert this force operates not only on the covering but on all com-parable pairs and thus encourages chains to be drawn in a single line. Similarly,incomparable elements should not be close to each other and thus the force f rep ( (cid:126)p a , (cid:126)p b ) = c hor d x ( (cid:126)p a ,(cid:126)p b ) · (cid:126)u x ( (cid:126)p a , (cid:126)p b ) , repels incomparable pairs horizontally.We call the case that an element would be placed above a comparable greaterelement or below a lesser element, overshooting . However, to ensure that everyintermediate drawing that is computed in the node step still satisfies the verticalinvariant we have to prohibit overshooting. Therefore, we add overshooting pro-tection to the step in the algorithm where ( (cid:126)p a ) a ∈ X is recomputed. This is done byrestricting the movement of every element such that it is placed maximally c vert below the lowest positioned greater element, or symmetrically above the greatestlower element. If the damping factor is chosen sufficiently small overshooting israrely required. This is, because our forces are defined such that the closer twoelements are positioned the stronger they repel each other, see Figure 3.All three forces are then consolidated into a single routine that is repeated atmost K times or until the total stress falls below a constant ε , see Algorithm 3.The general idea of our forces is similar to the forces described in Freese’s ap-proach, as comparable elements attract each other and incomparable elementsrepel each other. However, we are able to get rid of the ranking function thatfixes y -coordinate and thus have an additional degree of freedom which allowsus to include the horizontal distance as a factor to determine the vertical po-sitions. Furthermore, our forces are formulated in a general way such that thedrawings can be computed in arbitrary dimensions, while Freese is restricted tothree dimensions. This overcomes the problem of getting stuck in local minimaand enables us to recompute the drawing in two dimensions in the last cycle. While the goal of the node step is to get a good representation of the in-ternal structure by optimizing on the proximity of nodes, the goal of the linestep is to make the resulting drawing more aesthetically pleasing by optimizingdistances between lines. Thus, in this step the drawing is optimized on three softcriteria. First, we want to maximize the number of parallel lines. Secondly, wewant to achieve large angles between two lines that are connected to the sameelement dot. Finally, we want to have a high distance between elements andnon-adjacent lines. We achieve a better fit to these criteria by applying a force-directed algorithm with three different forces, each optimizing on one criterion.While the previous step does not directly incorporate the path of the lines, thisstep incorporates those into its forces. Therefore, we call this step the line step .The first force of the line step operates on lines ( a, b ) and ( c, d ) with a (cid:54) = c and b (cid:54) = d if their cosine distance is below a threshold c par . The horizontal Algorithm 4
ReDraw - Line Step
Input:
Ordered set: ( X, ≤ ) Constants: K ∈ N , ε > , δ > ,Drawing p = ( (cid:126)p a ) a ∈ X ⊆ R d c par > , c ang > , c dist > Output:
Drawing: p = ( (cid:126)p a ) a ∈ X ⊆ R d t = 1 while t < K and max a ∈ X (cid:107) F a ( t ) (cid:107) > ε : A = {{ ( a, b ) , ( c, d ) } | a ≺ b, c ≺ d, d cos (( (cid:126)p a , (cid:126)p b ) , ( (cid:126)p c , (cid:126)p d )) < c par } B = {{ ( a, c ) , ( b, c ) } | ( a ≺ c, b ≺ c ) or ( c ≺ a, c ≺ b ) , d cos (( (cid:126)p a , (cid:126)p c ) , ( (cid:126)p b , (cid:126)p c )) < c ang } C = { ( a, ( b, c )) | a ∈ X, b ≺ c, d ( (cid:126)p a , ( (cid:126)p b , (cid:126)p c )) < c dist } for a ∈ X : F a ( t ) := (cid:80) { ( a,b ) , ( c,d ) }∈ A f par (( (cid:126)p a , (cid:126)p b ) , ( (cid:126)p c , (cid:126)p d )) + (cid:80) ( a, ( b,c )) ∈ C f dist ( (cid:126)p a , ( (cid:126)p b , (cid:126)p c )) − (cid:80) { ( b,a ) , ( c,d ) }∈ A f par (( (cid:126)p a , (cid:126)p b ) , ( (cid:126)p c , (cid:126)p d )) − (cid:80) ( b, ( a,c )) ∈ C f dist ( (cid:126)p a , ( (cid:126)p b , (cid:126)p c ))+ (cid:80) { ( a,c ) , ( b,c ) }∈ B f ang (( (cid:126)p a , (cid:126)p c ) , ( (cid:126)p b , (cid:126)p c )) for a ∈ X : (cid:126)p a := o v e r s h o o t i n g _ p r o t e c t i o n ( (cid:126)p a + δ · F a ( t ) ) t = t + 1 force f par (( (cid:126)p a , (cid:126)p b ) , ( (cid:126)p c , (cid:126)p d )) = − (cid:16) − d cos (( (cid:126)p a ,(cid:126)p b ) , ( (cid:126)p c ,(cid:126)p d )) c par (cid:17) · (cid:16) ( (cid:126)p b − (cid:126)p a ) x y b − y a − ( (cid:126)p d − (cid:126)p c ) x y d − y c (cid:17) operates on a and the force − f par (( (cid:126)p a , (cid:126)p b ) , ( (cid:126)p c , (cid:126)p d )) operates to b . This result ofthis force is thus that almost parallel lines are moved to become more parallel.Note, that this force becomes stronger the more parallel the two lines are.The second force operates on lines that are connected to the same dot andhave a small angle, i.e., lines with cosine distance below a threshold c ang .Let ( a, c ) and ( b, c ) be such a pair then the horizontal force operating on a isgiven by f ang (( (cid:126)p a , (cid:126)p c ) , ( (cid:126)p b , (cid:126)p c )) = (cid:16) − d cos (( (cid:126)p a ,(cid:126)p c ) , ( (cid:126)p b ,(cid:126)p c )) c ang (cid:17) · (cid:16) ( (cid:126)p c − (cid:126)p a ) x y c − y a − ( (cid:126)p c − (cid:126)p b ) x y c − y b (cid:17) . In this case, once again the force is stronger for smaller angles; however, the forceis operating in the opposite direction compared to f par and thus makes the twolines less parallel. Symmetrically, for each pair ( c, a ) and ( c, b ) the same forceoperates on a . There are artifacts from f par that operate against f ang in oppositedirection. This effect should be compensated for by using a much higher thresh-old constant c ang than c par , otherwise the benefits of this force are diminishing.Finally, there is a force that operates on all pairs of element dots a and lines ( b, c ) , for which the distance between the element and the line is closer then c dist .The force f dist ( (cid:126)p a , ( (cid:126)p b , (cid:126)p c )) = d ( (cid:126)p a , ( (cid:126)p b ,(cid:126)p c )) · (cid:16) ( (cid:126)p a − (cid:126)p c ) − ( (cid:126)p a − (cid:126)p c ) · ( (cid:126)p b − (cid:126)p c )( (cid:126)p b − (cid:126)p c ) · ( (cid:126)p b − (cid:126)p c ) ( (cid:126)p b − (cid:126)p c ) (cid:17) is applied to a and − f dist ( a, ( c, d )) / is applied to b and c . This results in aforce whose strength is linearly stronger, the closer the distance d ( (cid:126)p a , ( (cid:126)p b , (cid:126)p c )) .It operates in perpendicular direction to the line and repels the dot and the line.Similar to the node step, all three forces are combined into a routine that isrepeated until the remaining energy in the physical system drops below a certainstress level ε . Furthermore a maximal number of repetitions K is fixed. Wealso once again include the overshooting protection as described in the previoussection to make sure that the vertical invariant stays satisfied. orce-Directed Layout of Order Diagrams using Dimensional Reduction 11 The line step that is described in this section is a computational demandingtask, as in every repetition of the iterative loop the sets of almost parallel edges,small angles and elements that are close to lines have to be recomputed. Tocircumvent this problem on weaker hardware, there are a number of possiblespeedup techniques. First of all, the sets described above do not have to berecomputed every iteration, but can be cashed over a small number of iterations.In Algorithm 4 these are the sets A , B and C . By recomputing those sets onlyevery k -th iteration a speedup to almost factor k can be achieved. Anotherspeedup technique that is possible is to only execute the line step in the lastround. Both of these techniques however have a trade off for the quality of thefinal drawing and are thus not further examined in this paper. In the dimension reduction step, we compute a ( d − -dimensional drawingfrom the d -dimensional drawing with the goal of reflecting the structural detailsof the original drawing like proximity and angles. Our approach to solve this isto compute a ( d − -dimensional linear subspace of the d -dimensional space. Bypreserving the vertical dimension we can ensure that the vertical invariant stayssatisfied. Then a parallel projection into this subspace is performed.As such a linear subspace always contains the origin, we center our drawingaround the origin. Thereby, the whole drawing ( (cid:126)p a ) a ∈ X is geometrically trans-lated such that the mean of every coordinate becomes 0. The linear subspaceprojection is performed as follows: The last coordinate of the linear subspace willbe the vertical component of the d -dimensional drawing to ensure that the verti-cal invariant is preserved. For the other ( d − dimensions of the original space,a principle component analysis [13] is performed to reduce them to a ( d − -dimensional subspace. By combining this projection with the vertical dimensiona ( d − -dimensional drawing is achieved, that captures the structure of theoriginal, higher-dimensional drawing and represents its structural properties.It is easily possible to replace PCA in this step by any other dimension reduc-tion technique. It would thus be thinkable to just remove the first coordinate ineach step and hope that the drawing in the resulting subspace has enough infor-mation encapsulated in the remaining coordinates. Also other ways of choosingthe subspace in which is projected could be considered. Furthermore, non-lineardimension reduction methods could be tried in order to achieve drawings, how-ever our empirical experiments suggest, that PCA hits a sweet spot. The payoffof more sophisticated dimension reduction methods seems to be negligible aseach drawing is further improved in lower dimensions. On the other hand weobserved local minima if we used simpler dimension reduction methods. As we described in the previous sections, it is not a trivial task to evaluate thequality of an order diagram drawing. Drawings that one human evaluator might
Fig. 4: Top: Drawing of the lattices for the formal contexts “forum romanum”(top) and “living beings and water” (bottom) from the test dataset.consider as favorably might not be perceived as readable by others. Therefore,we evaluate our generated drawing with a large quantity of domain experts.
The run-time of the node step is limited by O ( n ) with n being the number ofelements, as the distances between every element pair are computed. The run-time of the edge step is limited by O ( n ) , as the number of lines is boundedby O ( n ) . Finally, the run-time of the reduction step is determined by PCAwhich is known to be bounded by O ( n ) . Therefore, the total run-time of thealgorithm is polynomial in O ( n ) . This is an advantage compared to DimDrawand Sugiyama’s framework, which both solve exponential problems; however,Sugiyama is usually applied with a combination of heuristics to overcome thisproblem. Freese’s layout has by its nature of being a force-directed order dia-gram drawing algorithm, similar to our approach, polynomial run-time. Thus,for larger diagrams, only ReDraw , Freese’s algorithm and Sugiyama’s framework(the latter with its heuristics) are suitable, while DimDraw is not.
Our test dataset consists of 77 different lattices including all classical examplesof lattices described in [9]. We enriched these by lattices of randomly generated orce-Directed Layout of Order Diagrams using Dimensional Reduction 13(a) Sugiyama (b) Freese (c) DimDraw (d) ReDraw w/oline step (e) ReDraw withline step(a) Sugiyama (b) Freese (c) DimDraw (d) ReDraw w/oline step (e) ReDraw withline step
Fig. 5: Top: Drawing of the lattices for the formal contexts “therapy” (top) and“ice cream” (bottom) from the test dataset.contexts and some sampled contexts from large binary datasets. An overview ofall related formal contexts for these lattices, together with their drawing gener-ated by
ReDraw is published together with its source code. We restrict the testdataset to lattices, as lattice drawings are of great interest for the formal con-cept analysis community. This enables us to perform a user study using domainexperts for lattices from the FCA community to evaluate the algorithm.
As it is hardly possible to conduct a user study for every single combination ofparameters, our recommendations are based on empirical observations. We useda maximal number of K = 1000 algorithm iterations or stopped if the stress inthe physical system fell below ε = 0 . . Our recommended damping factor δ = 0 . . In the node step we set c vert = 1 as the optimal horizontal distanceand c hor = 5 . We used the thresholds c par = 0 . , c ang = 0 . and c dist = 1 in the line step. The drawing algorithms are started with 5 dimensions as wedid not observe any notable improvements with higher dimensional drawings.Finally the resulting drawing is scaled in horizontal direction by a factor of 0.5. To demonstrate the quality of our approach we compare the resulting drawings tothe drawings generated by a selected number of different algorithms in Figure 4 and Figure 5. The different drawings are computed using Sugiyama’s framework,Freese’s layout, DimDraw and our new approach. Additionally, a drawing of ourapproach before the line step is presented to show the impact of this line step.In the opinion of the authors of this paper, the approach proposed in this paperachieves satisfying results for these ordered sets. In most cases, we still prefer theoutput of DimDraw (and sometimes Sugiyama), but
ReDraw is able to cope withmuch larger datasets because of its polynomial nature. Modifications of
ReDraw that combine the node step and the edge step into a single step were tried by theauthors; however, the then resulting algorithm did not produce the anticipatedreadability, as the node and edge forces seem to work against each other.
To obtain a measurable evaluation we conducted a user study to compare thedifferent drawings generated by our algorithm to two other algorithms. We de-cided to compare our approach to Freese’s and Sugiyama’s algorithm, as thosetwo seem to be the two most popular algorithms for lattice drawing at the mo-ment. We decided against including DimDraw into this study as, even though itis known to produce well readable drawings, it struggles with the computationalcosts for drawings of higher order dimensions due to its exponential nature.
Experimental Setup.
In each step of the study, all users are presentedwith three different drawings of one lattice from the dataset in random orderand have to decide which one they perceive as “most readable”. The term “mostreadable” was neither further explained nor restricted.
Results.
The study was conducted with nine experts from the formal con-cept analysis community to guarantee expertise with order diagrams among theparticipants. Thus, all ordered sets in this study were lattices. The experts voted582 times in total; among those votes, 35 were cast for Freese’s algorithm, 266for our approach and 281 for Sugiyama. As a common property of lattices is tocontain a high degree of truncated distributivity [15], which makes this propertyof special interest, we decided to compute the share of distributive triples foreach lattice excluding those resulting in the bottom-element. We call the shareof such distributive triples of all possible triples the truncated relative distribu-tivity (RTD) . Based on the RTD we compared the share of votes for Sugiyama’sframework and
ReDraw for all order diagrams that are in a specific truncated dis-tributivity range. The results of this comparison are depicted in Figure 6. Thehigher the RTD, the better
ReDraw performs in comparison. The only exceptionin the range 0.64-0.68 can be traced back to a small test set with n = 4 . Discussion.
As one can conclude from the user study, our force-directedalgorithm performs on a similar level to Sugiyama’s framework while outper-forming Freese’s force-directed layout. In the process of developing
ReDraw wealso conducted a user-study that compared an early version to DimDraw whichsuggested that
ReDraw can’t compete with DimDraw. However, DimDraw’s ex-ponential run-time makes computing larger order drawings unfeasible. From thecomparison of
ReDraw and Sugiyama’s, that takes the RTD into account, we canfollow that our algorithm performs better on lattices the higher the RTD. We orce-Directed Layout of Order Diagrams using Dimensional Reduction 15
Fig. 6: Results of the user study. L: Number of votes for each algorithm. R: Shareof votes for ordered sets divided into ranges of different truncated distributivity.observed similar results when we computed the relative normal distributivity.The authors of this paper thus recommend to use
ReDraw for larger drawingsthat are highly distributive. Furthermore, the authors observed, that
ReDraw performs better if there are repeating structures or symmetries in the lattice aseach instance of such a repetition tends to be drawn similarly. This makes it thealgorithm of choice for ordered sets that are derived from datasets containinghigh degrees of symmetries. Anyway, the authors of this paper are convincedthat there is no single drawing algorithm that can produce readable drawingsfor all different kinds of order diagrams. It is thus always recommended to use acombination of different algorithms and then decide on the best drawing.
In this work we introduced our novel approach
ReDraw for drawing diagrams.Thereby we adapted a force-directed algorithm to the realm of diagram drawing.In order to guarantee that the emerging drawing satisfies the hard conditions oforder diagrams we introduced a vertical invariant that was satisfied in every stepof the algorithm. The algorithm consists of two main ingredients, the first beingthe node step that optimizes the drawing in order to represent structural proper-ties using the proximity of nodes. The second is the edge step that improves thereadability for a human reader by optimizing the distances of lines. Of particularinterest is the line step that enhances the quality of the produced drawings as,to our knowledge, it is the first of its kind. To avoid local minima, our draw-ings are first computed in a high dimension and then iterativly reduced into twodimensions. To make the algorithm easily accessible, we published the sourcecode and gave recommendations for parameters. Generated drawings were, inour opinion, suitable to be used for ordinal data analysis. A study using domainexperts to evaluate the quality of the drawings confirmed this observation.Further work in the realm of order diagram drawing could be to modify theline step and combine it with algorithms such as DimDraw. Also modifications that produce additive drawings are of great interest and should be investigatedfurther. Finally, in the opinion of the authors the research fields of ordinal dataanalysis and graph drawing would benefit significantly from the establishmentof a “readability measure” or at least of a decision procedure that, given twovisualizations of the same ordered set identifies the more readable one.
References
1. Albano, A., Chornomaz, B.: Why concept lattices are large: extremal theory forgenerators, concepts, and vc-dimension. Int. J. Gen. Syst. (5), 440–457 (2017)2. Battista, G.D., Eades, P., Tamassia, R., Tollis, I.G.: Graph Drawing: Algorithmsfor the Visualization of Graphs. Prentice-Hall (1999)3. Demel, A., Dürrschnabel, D., Mchedlidze, T., Radermacher, M., Wulf, L.: A greedyheuristic for crossing-angle maximization. In: Biedl, T.C., Kerren, A. (eds.) GraphDrawing and Network Visualization - 26th International Symposium, GD 2018,Barcelona, Spain, September 26-28, 2018, Proceedings. Lecture Notes in ComputerScience, vol. 11282, pp. 286–299. Springer (2018)4. Dürrschnabel, D., Hanika, T., Stumme, G.: Drawing order diagrams through two-dimension extension. CoRR abs/1906.06208 (2019)5. Eades, P.: A heuristic for graph drawing. Congressus Numerantium , 149–160(1984)6. Freese, R.: Automated lattice drawing. In: Eklund, P.W. (ed.) Concept Lattices,Second International Conference on Formal Concept Analysis, ICFCA 2004, Syd-ney, Australia, February 23-26, 2004, Proceedings. Lecture Notes in ComputerScience, vol. 2961, pp. 112–127. Springer (2004)7. Fruchterman, T.M.J., Reingold, E.M.: Graph drawing by force-directed placement.Softw. Pract. Exp. (11), 1129–1164 (1991)8. Ganter, B.: Conflict avoidance in additive order diagrams. Journal of UniversalComputer Science (8), 955–966 (2004)9. Ganter, B., Wille, R.: Formal Concept Analysis - Mathematical Foundations.Springer (1999)10. Hong, S., Eades, P., Lee, S.H.: Drawing series parallel digraphs symmetrically.Comput. Geom. (3-4), 165–188 (2000)11. Hopcroft, J.E., Tarjan, R.E.: Efficient planarity testing. J. ACM (4), 549–568(1974)12. Nishizeki, T., Rahman, M.S.: Planar Graph Drawing, Lecture Notes Series onComputing, vol. 12. World Scientific (2004)13. Pearson, K.: Liii. on lines and planes of closest fit to systems of points in space. TheLondon, Edinburgh, and Dublin Philosophical Magazine and Journal of Science (11), 559–572 (1901)14. Sugiyama, K., Tagawa, S., Toda, M.: Methods for visual understanding of hierar-chical system structures. IEEE Trans. Syst. Man Cybern. (2), 109–125 (1981)15. Wille, R.: Truncated distributive lattices: Conceptual structures of simple-implicational theories. Order20