graph layout with versatile boundary constraintspang/261/f15/misc/yani.pdf · 2019-06-02 · there...

10
1 Graph Layout with Versatile Boundary Constraints Yani Zhang 1 and Alex Pang 2 1 Expedia Inc., 2 Computer Science Department, University of California Santa Cruz Graph layouts are in general data dependent and help to reveal structural and attribute relationships in the data set. However, there are situations when one may wish to alter the layout e.g. to emphasize parts of the data set or for aesthetic reasons. This paper strives to meet that need for the case of force-directed graph layout algorithms. Our approach is to add boundary constraints to specify where graph nodes may or may not be positioned. Users can interactively draw one or more boundaries. Boundaries may self-intersect and define different topology e.g. donut or figure eight shapes. Additional control, subject to the density of nodes, can impart different density distributions within defined boundaries. We tested the feasibility of this concept on several data sets and different boundary constraints. I. I NTRODUCTION Graph drawing has been an area of active research interest in the information visualization community as abstract graph models are widely used in various areas ranging from social networks, security, scientific applications, and others. Among those techniques [1], [15], [7], [20], [2], force-directed ap- proach [3], [9], [5], [21], [11], [12], [13], [4], [18], [23], [29], [16], [24] is the most well-known method for drawing undirected graphs due to their flexibility of adding constraints, ease of implementation and generally satisfactory layouts. Specifically, a graph is viewed as a neat drawing of the node particles that can be generated by minimizing an energy function [20]. Based on this force-directed idea, many practical graph drawing systems have been developed. In general, layout is dictated by using a repulsive force to separate vertices apart from each other and a pseudo-gravity force to hold the entire graph together but without constraining the size and shape of the graph. In certain situations, one would like the layout to meet some specific requirements or common aesthetics such as symmetry, minimum edge crossings, etc. while at the same time, obtain the desired graph with a minimum amount of time. With these goals in mind, various kinds of constraints were taken into account in constrained graph layouts [14], [25], [19], [8]. Widely used graph drawing constraints include placing a given vertex in the center or on the outer boundary of the drawing, placing a group of vertices as a cluster, or aligning vertices horizontally or vertically [25]. Thus, drawing a graph using force-directed methods can be formalized as a complex multi-objective optimization problem. In this paper, we propose an alternative approach to specify constraints by allowing the users to interactively draw a boundary wherein the graph layout will be constrained. We model these boundaries as a set of additional environmental forces that contribute to the forces acting on the vertices in the graph. Since our approach is based on force-directed simulation, it can take advantage of the existing optimization results from other force-directed graph layout algorithms. The remainder of this paper is organized as follows. We dis- cuss related work with aspects of interactivity and constraints in graph drawing methods in section II. Section III provides a basic background on force-directed methods and the definition of our graph drawing problem. In section IV we give a formal definition of boundary constraints and present our new force- directed model with boundary constraints. Implementation work is discribed in section V and boundary constrained layout of graphs and analysis of results are presented in section VI. We provide conclusions and identify some avenues for future work in section VII. II. RELATED WORK A. Interactivity There are many interactive constraint-based graph layout systems in existence today. However, they do not include outside environment force as additional constraints to the graph drawings. For example, the GLIDE (Graph Layout Interactive Diagram Editor) system [22] is a graph editor for drawing medium-sized graphs that organizes the interaction within a vocabulary of specialized constraints for graph draw- ing. CGV (Coordinated Graph Visualization) [26] is another graph visualization system that incorporates several interactive views to address different aspects of graph visualization. These graph drawing systems indeed focus on interaction but did not support interactively defining boundary constraints for graph layouts. Alternatively, there are constraints-driven layout algorithms for network diagrams [6], which propose a variety of layout techniques to exhibit the Visual Organization Features (VOFs). VOFs are arrangements of related vertices in the diagram including horizontal and vertical alignment, axial and radial symmetries, etc. However, these VOFs do not include con- straining the graph within an area where the desired shape can be achieved. Such boundary constraints can be useful in many applications such as automatic graph layout, network graph analysis and visual design. Note that while very powerful, focussing mechanisms used in magnification, fisheye, or other layout lenses [27] are different in that they typically deal with only a subset of the graph or the layout space. B. Constraints in Graph Drawing Methods Traditional methods that incorporate boundary constraints controlled the size of the graph layout by assuming that

Upload: others

Post on 01-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Graph Layout with Versatile Boundary Constraintspang/261/f15/misc/yani.pdf · 2019-06-02 · There are many interactive constraint-based graph layout systems in existence today. However,

1

Graph Layout with Versatile Boundary ConstraintsYani Zhang1 and Alex Pang2

1Expedia Inc.,2Computer Science Department, University of California Santa Cruz

Graph layouts are in general data dependent and help toreveal structural and attribute relationships in the data set.However, there are situations when one may wish to alter thelayout e.g. to emphasize parts of the data set or for aestheticreasons. This paper strives to meet that need for the caseof force-directed graph layout algorithms. Our approach istoadd boundary constraints to specify where graph nodes mayor may not be positioned. Users can interactively draw oneor more boundaries. Boundaries may self-intersect and definedifferent topology e.g. donut or figure eight shapes. Additionalcontrol, subject to the density of nodes, can impart differentdensity distributions within defined boundaries. We testedthefeasibility of this concept on several data sets and differentboundary constraints.

I. I NTRODUCTION

Graph drawing has been an area of active research interestin the information visualization community as abstract graphmodels are widely used in various areas ranging from socialnetworks, security, scientific applications, and others. Amongthose techniques [1], [15], [7], [20], [2], force-directedap-proach [3], [9], [5], [21], [11], [12], [13], [4], [18], [23],[29], [16], [24] is the most well-known method for drawingundirected graphs due to their flexibility of adding constraints,ease of implementation and generally satisfactory layouts.Specifically, a graph is viewed as a neat drawing of thenode particles that can be generated by minimizing an energyfunction [20].

Based on this force-directed idea, many practical graphdrawing systems have been developed. In general, layout isdictated by using a repulsive force to separate vertices apartfrom each other and a pseudo-gravity force to hold the entiregraph together but without constraining the size and shape ofthe graph. In certain situations, one would like the layout tomeet some specific requirements or common aesthetics suchas symmetry, minimum edge crossings, etc. while at the sametime, obtain the desired graph with a minimum amount of time.With these goals in mind, various kinds of constraints weretaken into account in constrained graph layouts [14], [25],[19],[8]. Widely used graph drawing constraints include placingagiven vertex in the center or on the outer boundary of thedrawing, placing a group of vertices as a cluster, or aligningvertices horizontally or vertically [25]. Thus, drawing a graphusing force-directed methods can be formalized as a complexmulti-objective optimization problem.

In this paper, we propose an alternative approach to specifyconstraints by allowing the users to interactively draw aboundary wherein the graph layout will be constrained. We

model these boundaries as a set of additional environmentalforces that contribute to the forces acting on the verticesin the graph. Since our approach is based on force-directedsimulation, it can take advantage of the existing optimizationresults from other force-directed graph layout algorithms.

The remainder of this paper is organized as follows. We dis-cuss related work with aspects of interactivity and constraintsin graph drawing methods in section II. Section III providesabasic background on force-directed methods and the definitionof our graph drawing problem. In section IV we give a formaldefinition of boundary constraints and present our new force-directed model with boundary constraints. Implementationwork is discribed in section V and boundary constrained layoutof graphs and analysis of results are presented in section VI.We provide conclusions and identify some avenues for futurework in section VII.

II. RELATED WORK

A. Interactivity

There are many interactive constraint-based graph layoutsystems in existence today. However, they do not includeoutside environment force as additional constraints to thegraph drawings. For example, the GLIDE (Graph LayoutInteractive Diagram Editor) system [22] is a graph editor fordrawing medium-sized graphs that organizes the interactionwithin a vocabulary of specialized constraints for graph draw-ing. CGV (Coordinated Graph Visualization) [26] is anothergraph visualization system that incorporates several interactiveviews to address different aspects of graph visualization.Thesegraph drawing systems indeed focus on interaction but did notsupport interactively defining boundary constraints for graphlayouts.

Alternatively, there are constraints-driven layout algorithmsfor network diagrams [6], which propose a variety of layouttechniques to exhibit the Visual Organization Features (VOFs).VOFs are arrangements of related vertices in the diagramincluding horizontal and vertical alignment, axial and radialsymmetries, etc. However, these VOFs do not include con-straining the graph within an area where the desired shape canbe achieved. Such boundary constraints can be useful in manyapplications such as automatic graph layout, network graphanalysis and visual design. Note that while very powerful,focussing mechanisms used in magnification, fisheye, or otherlayout lenses [27] are different in that they typically dealwithonly a subset of the graph or the layout space.

B. Constraints in Graph Drawing Methods

Traditional methods that incorporate boundary constraintscontrolled the size of the graph layout by assuming that

Page 2: Graph Layout with Versatile Boundary Constraintspang/261/f15/misc/yani.pdf · 2019-06-02 · There are many interactive constraint-based graph layout systems in existence today. However,

2

the boundary of the pre-specified drawing region acted asa wall [12]. Regions were rectangular in shape and wererepresented as inequality constraints wherein graph verticesmust lie. No forces were used in their formulation.

Other forms of constrained graph layout models have alsobeen proposed. A formalism for the declarative specificationof graph drawing with Prolog and an associated constraint-solving mechanism have been developed by Kamada [17]. Us-ing this formalism, one can express several simple geometricconstraints among the vertices, such as horizontal or verticalalignment, and circular arrangements. Dengler [6] provideda notation for describing the desired perceptual organizationof a layout of a graph by means of a collection of layoutpatterns based on positions. These include clustering, zoning,sequential placement, T- shape, and hub shape. This methodincrementally improves an initial randomly-generated drawing.

A comprehensive approach for constrained graph drawingwas presented by He and Marriot [14]. They provide ageneral model that supports: (i) the specification of arbitraryarithmetic linear equality and inequality constraints on thecoordinates of the vertices; (ii) suggests coordinates forthevertices, each with an associated weight, which denotes thestrength of the suggestion. They show how to extend the force-directed approach by Kamada [18] to support such placementconstraints which is fast and produces good results in practice.

The above mentioned force-directed methods are all sup-ported by the position constraints of vertices or fixed-subgraphconstraints in the graph, but our approach is based on addingan additional force to constrain the whole graph. The benefitof our approach is that the additional boundary forces are pro-cessed in the same way as forces acting on graph elements andtherefore converge at the same rate. In contrast, with the othermethods mentioned above, more work has to be done aftereach iteration to take into account position constraints. Thus,our approach achieves better interactivity with user becausethe graph would take boundary constraints into considerationwhile converging to the final layout.

III. F ORCE-DIRECTED GRAPH LAYOUT

A. Definitions

1) Graph: In force-directed methods, a graphG is definedas a pair(VG, EG) whereVG is a set of vertices andEG isa set of edgesEG ⊂ VG × VG. A drawing of such graphG on the plane is defined as a mappingD from VG to R

2,whereR is the set of real numbers. Then for mappingD, eachvertexv ∈ VG is placed at pointD(v) on the plane, and eachedge(u, v) ∈ EG for u, v ∈ VG is displayed as a straight-linesegment connectingD(u) andD(v). In our graph drawings,we use a dot on the plane to represent a vertex and a straightline connecting two vertices to represent an edge.

2) Boundary: Similarly, a boundaryBp of the graph isdefined also as a pair(VBp, EBp). Suppose boundaryBp hasn vertices (which we will refer to as boundary vertices todistinguish them from graph vertices) andm edges (whichwe will refer to as boundary edges to distinguish them fromgraph edges), thenVBp is defined as a set of boundary verticesVBp = {vp(1), vp(2), · · · , vp(n)} andEBp is defined as a set

of boundary edges that connects adjacent vertices and formsaconnected path. That is,EBp = {ep(1), ep(2), · · · , ep(m)}where ep(i) = vp(i)vp(i+ 1) (i = 1, 2, · · · ,m − 1) andfor special casei = m, ep(m) = vp(m)vp(1). Note thatwhile we use the graph notation to represent a boundary, itis a special case wheren = m, and it forms a closed loop.The coordinates of the boundary vertices in the mappingDare defined interactively by users, so the boundary can bedeformed into arbitrary shapes and may even self-intersect.Multiple boundaries in the same graph are allowed to supportboundaries of different topologies. In these cases, the bound-aries are represented by a set composed ofB1, B2, · · · , Bq

to specifyq distinct boundaries. While there is flexibility interms of how boundaries are represented and the differenttypes of topology that one can construct, one must neverthelessbe careful about the semantics of these boundaries in termsof using them as boundary constraints for graph placement.Also, while an individual boundary may self-intersect, we donot allow a boundary to intersect with another boundary.

B. Common Forces

Now we introduce some common forces in classical force-directed methods. The graph drawing algorithm of Tutte [28]is one of the earliest force-directed method in literature.Themodel they proposed partitions the set of vertices into two sets,a set of fixed vertices and a set of free vertices. By nailingdown the fixed vertices as a strictly convex polygon and thenplacing each free vertex at the barycenter of its immediateneighbor during each iteration, the model is able to yield a nicedrawing. Subsequently, Eades [9] proposed a simple springembedder algorithm which most models today, including ourproposed model, is built upon.

In that model, every pair of vertices is connected by aspring (although Eades’ model did not use Hooke’s Law). Foradjacentvertices (vertices that are connected to each other byan edge), the intensityfs of the attractive spring force exertedon the two vertices depends on the current distance betweenthem according to the following formula:

fs(uv) = c1 · log( |uv|

c2

)

uv

|uv| (1)

wherec1 represents a scaling constant for spring force,c2 isthe given spring natural length, anduv denotes the vector fromvertexu to vertexv.

For non-adjacentvertices (vertices that are not connected toeach other by an edge), the spring has infinite natural length,thus always has a repelling force. The intensityfr of therepulsive force exerted on the two vertices depends on thedistance between them:

fr(uv) = −(

c3|uv|2

)

uv

|uv| (2)

wherec3 is the scaling constant for repulsive forces.In general, various modifications on force-directed ap-

proaches fall into two categories. One has to do with alteringthe repulsive force and the spring force models, while the otherattempts to manipulate the local minima problem resulting

Page 3: Graph Layout with Versatile Boundary Constraintspang/261/f15/misc/yani.pdf · 2019-06-02 · There are many interactive constraint-based graph layout systems in existence today. However,

3

from the equilibrium between repulsive forces and the springforces. This paper is based on the first approach, where weadd an additional force representing the boundary constraintsinto the graph layout optimization process.

C. Graph Drawing Problem

The graph drawing problem considered in our paper isaddressed as follows: Suppose we begin with a randomlypositioned drawing of a graphG = (VG, EG) and a set ofboundaries{B1, B2, · · · , Bq} to specifyq distinct boundaries,the layout algorithm should solve the optimization problemand satisfy the following goals:

• Minimize energy configuration.• Every vertex of the graph is within the defined bound-

aries.• The final layout of the graph preserves the properties of

force-directed methods.

IV. L AYOUT WITH BOUNDARY CONSTRAINTS

In this section, we first give a formal definition of boundaryconstraints and the forces they induce on the graph elements.Then we discuss our layout algorithm in depth including howthe attractive and repulsive forces are modified to accountfor boundaries, and how the boundary forces are calculated.Finally, we present the algorithm for handling boundary con-straints.

A. Definition of Active Area

Boundary constraints are enforced via boundary forces ongraph elements. In order to determine how these boundaryforces affect graph elements, we must determine the set ofboundary edges that can influence an individual graph element,or conversely, the set of graph elements affected by a boundaryforce. For this purpose, we define the active area of a set ofboundaries, and the active area of each boundary edge.

1) Active Area of A Set of Boundaries:A boundary spec-ifies a partitioning of the space wherein a graph is to bedrawn. For closed boundaries, we need to distinguish betweenthe inside and outside of the boundary. By convention, wewill assume that boundary vertices are ordered in a counter-clockwise manner so that the inside is to theleft of a boundaryedge (see Fig. 1(a)). Furthermore, each boundaryBp enclosesan area. For simplicity, we will use the notationBp to representboth the boundary and its enclosed area. Each boundary has itsown active areaAp which is encompassed byBp. For the casewhere there is only one boundary, as illustrated in Fig. 1(a),the active area isAp (p = 1). In general, if we have morethan one boundary and there are containments between thoseboundaries, then we define the active areaA as the biggestconnected area where the graph layout can take place. Forexample, let us assumeB1 is the outer boundary, with smallerboundaries scattered withinB1 as shown in Fig. 1(b). Thenthe active area in that figure isA = B1 − (B2 + B3). Ingeneral, assuming that boundaries do not intersect each otheri.e. there is only a single connected area whose outer perimeteris specified byB1, and thatB2 · · ·Bq do not intersect each

(a) One boundary case.

(b) Multiple boundaries case.

Fig. 1. Definition of active area of boundaries.

other and do not contain another boundary within each ofthem, then the active area of these boundaries can be expressedasA = B1−(B2+B3+· · ·+Bq). Violating these assumptionswould mean that there are several disjoint areas, rather than asingle contiguous area, where a single graph must be laid out.Any vertex falling inside the active areaA will have boundaryforces acting upon it.

2) Active Areas of A Boundary Edges:In general, a bound-ary edge will exert an inward force perpendicular to theboundary edge on graph elements in order to keep them withinthe boundary. However, not all boundary edges will affectgraph vertices at all times. A graph vertexvG(j) is influencedby a boundary edge only when it is within the active area ofthat edge. Given a boundary edgeep(i) belonging to boundaryBp, the active area ofep(i) is the half space bounded on theleft by a vector (which we call the left vector) from boundaryvertexvp(i) and on the right by a vector (which we call theright vector) from boundary vertexvp(i + 1) as indicatedin Fig. 2. The four graph vertices within the active area ofep(i) are each assigned a boundary forcefBp(vG(j), ep(i))(see Section IV-C) with a direction perpendicular toep(i)and pointing towards the interior of the boundary. For full

Page 4: Graph Layout with Versatile Boundary Constraintspang/261/f15/misc/yani.pdf · 2019-06-02 · There are many interactive constraint-based graph layout systems in existence today. However,

4

consideration of how to define left and right vectors, weneed to look at the types of boundary vertices that makeup a boundary edge. That is, whether the boundary vertexis concave or convex.

Fig. 2. Definition of active area of boundary edges.

In Fig. 3, boundary edgeep(i) is drawn as a solid vectorfrom boundary vertexvp(i) to vp(i+1). It is bounded on theleft by boundary edgeep(i− 1) and on the right by boundaryedgeep(i + 1). A boundary vertex, e.g.vp(i), is a convexboundary vertex if the interior angle of the boundary edgesthat share that vertex i.e. angle fromep(i − 1) to ep(i), isless than or equal to180 degrees. Otherwise it is a concaveboundary vertex, e.g.vp(i+ 1).

Fig. 3. Convex and concave boundary vertices.

The active area of a boundary edge depends on the typeof boundary vertices that make up an edge. As we processthe boundary edges in a counter-clockwise manner, there arefour cases to handle:

Case1: Both vp(i) andvp(i+1) are convex (see Fig. 4(a)):If both boundary vertices of boundary edgeep(i) are

convex, then the active area of boundary edgeep(i) isbounded by left vector−ep(i − 1), boundary edgeep(i) and

right vectorep(i+1). A force perpendicular to boundary edgeep(i) is applied to graph elements that are on the half spaceinside of boundary edgeep(i), and also inside of boundaryedge ep(i − 1) and boundary edgeep(i + 1). Otherwise,boundary edgeep(i) does not contribute a force to the graphelement.

Case 2: vp(i) is convex andvp(i + 1) is concave (seeFig. 4(b)):

We define the active area of boundary edgeep(i) to bebounded by left vector−ep(i − 1), boundary edgeep(i)and a vector fromvp(i + 1) to v2p(i + 1) as the rightvector. v1p(i + 1) is perpendicular toep(i) and v2p(i + 1)is perpendicular toep(i + 1). For graph elements fallingin the area bounded by left vector−ep(i − 1), boundaryedge ep(i) and vector vp(i+ 1)v1p(i + 1), we apply aforce perpendicular to boundary edgeep(i). For graphelements falling in the triangular gap bounded by vectorvp(i + 1)v1p(i+ 1) and right vectorvp(i + 1)v2p(i + 1), weapply a force in the direction fromvp(i + 1) to the graphelement.

Case 3: vp(i) is concave andvp(i + 1) is convex (seeFig. 4(c)):

We define the active area of boundary edgeep(i) to bebounded by a vector fromvp(i) to v2p(i) as the left vector,boundary edgeep(i), and boundary edgeep(i+1) as the rightvector. Graph elements inAi are applied a force perpendicularto boundary edgeep(i). For graph elements in the triangulargap bounded by vectorvp(i)v1p(i) and left vectorvp(i)v2p(i),we apply a force in the direction fromvp(i) to the graphelement. Note that ifvp(i) is a left concave boundary vertex ofboundary edgeep(i), then it is also the right concave boundaryvertex of boundary edgeep(i − 1) which is handled by case2 above.

Case4: Both vp(i) andvp(i+1) are concave (see Fig. 4(d)):For this case, we define the active area of boundary edge

ep(i) to be bounded by a vector fromvp(i) to v2p(i) as leftvector, boundary edgeep(i), and a vector fromvp(i + 1) tov2p(i + 1) as right vector. Just as in cases2 and 3, a leftconcave boundary vertex will be bounded by a vector that isperpendicular to the edge. Likewise, a right concave boundaryvertex will be bounded by a vector that is perpendicular to thenext boundary edge.

B. Different Types of Active Area

Here, we consider the number of active areas resulting fromeither a single or multiple boundaries, and whether their shapeor arrangement result in a single or multiple active areas wheregraph elements will be constrained. There are four possibleconfigurations which we discuss below.

1) Single Boundary and Single Active Area:(Fig. 1(a)) Thisis the simplest case, where the boundary constraint is specifiedby a single boundary and where the edges in this boundarydo not self-intersect. Graph elements will have forces applies

Page 5: Graph Layout with Versatile Boundary Constraintspang/261/f15/misc/yani.pdf · 2019-06-02 · There are many interactive constraint-based graph layout systems in existence today. However,

5

(a) Boundary vertexvp(i) is convex, boundary vertexvp(i+1) is also convex.

(b) Boundary vertexvp(i) is convex, boundary vertexvp(i+1) is concave.

(c) Boundary vertexvp(i) is concave, boundary vertexvp(i+1) is convex.

(d) Boundary vertexvp(i) is concave, boundary vertexvp(i+ 1) is also concave.

Fig. 4. Boundary edges and their active area.

to them if they are in the active area of each of the boundaryedges of the boundary. These forces are summed up to obtainthe net boundary constraint forces acting on a graph element.The resulting boundary constraint force is then factored intogether with other force-directed components i.e. springandgravitation forces, to effect a change in the position of thegraph element.

2) Single Boundary and Multiple Active Area:(Fig. 5) Thisscenario happens when boundary edges intersect each other.As an example, boundary edgeep(i − 1) and boundary edgeep(i+1) intersect each other atvp. This results in two separateactive areasA1 andA2, which we treat as two single activeareas. In this case, the resulting layout of a graph will be highlydependent on the initial configuration or position of the graphelements. If the graph to be laid out is a single connectedgraph, i.e. all the nodes are connected together, then the finallay out of the graph will be constrained to be in eitherA1

or A2. If the graph to be laid out contains multiple disjointcomponents i.e. the graph is actually a forest, then differentparts of the forest will end up inA1 or A2 depending ontheir initial positions prior to activating the boundary constraintforces.

Fig. 5. Single boundary and multiple active area.

3) Multiple Boundaries and Single Active Area:(Fig. 6)Recall that boundary vertices are specified in a counter-clockwise order so that a sense of what is inside or outsidethe boundary can be established. In Fig. 6, boundaryB2 isfully inside boundaryB1. The active areaA = B1 −B2, is asingle connected active area. Each of the boundary edges willexert a boundary constraint force in the direction described inSection IV-C. A graph to be laid out, whether it is a singleconnected graph or a forest, will be constrained to fully residewithin the active areaA.

4) Multiple Boundaries and Multiple Active Area:Multipleactive areas can arise from certain arrangements of multipleboundaries. If boundaries are nested with alternating inside-outside orientations as in Fig. 7, then one can obtain multipledisjoint active areas. For such cases, the same behavior asillustrated in Fig. 5 can be expected. That is, the final layoutis sensitive to the initial layout of the graph. Also, if thegraph is a single connected graph, it will end up in one of

Page 6: Graph Layout with Versatile Boundary Constraintspang/261/f15/misc/yani.pdf · 2019-06-02 · There are many interactive constraint-based graph layout systems in existence today. However,

6

Fig. 6. Multiple boundaries and single active area.

the active areas; and if it is a forest, then different parts willgo to different active areas.

Aside from this scenario, there are other ways to obtainmultiple active areas using multiple boundaries. For example,one of the enclosed boundaries may be a self-intersectingboundary, or two of the enclosed boundaries intersect eachother. We do not consider these cases in this paper.

Fig. 7. Multiple boundaries and multiple active area.

C. Boundary Forces

Before we assign boundary force to each graph vertex wehave to know if the graph vertex is within the boundary. Thistest can be carried out using a point in polygon test such asthe one described by Franklin [10]. This is an efficientO(m)test that depends on the number of edges defining a boundary,and can handle self-intersecting polygons properly.

If the graph vertexvG(j) is within the boundaryBp, thenwe start testing if it is within each active area of boundaryedges. Take Fig. 8 as an example, we have a convex bound-ary vertexvp(i), and a concave boundary vertexvp(i + 1).First we consider boundary edgeep(i) and its active areaAi bounded by its left vector−ep(i − 1), boundary edge

ep(i) and vectorv1p(i + 1). We construct two new vectorsvec1(i) = vG(j)− vp(i) andvec2(i) = vG(j)− vp(i+ 1), ifboth of them fall within active areaAi, i.e. vec1(i) is alwaysbetween left vector of active areaAi and boundary edgeep(i),and vec2(j) is always between right vector of active areaAi and vectorvp(i + 1)vp(i), then the graph vertexvG(j)is considered within the active areaAi. So in Fig. 8,vG(1)is considered within active areaAi, but vG(2) is not. Let thedistance fromvG(j) to boundary edgeep(i) be de(i) and avector ver(i) be perpendicular to boundary edgeep(i) andpointing towards the interior of the boundaries. That is,

de(i) =vec1(i) · ver(i)

|ver(i)|(3)

Then the boundary forcefBp acting on the graph vertexvG(j)from boundary edgeep(i) is defined as:

fBp(vG(j), ep(i)) = c5 ·1

de(i)· ver(i)

|ver(i)|i = 1, 2, · · · , n, j = 1, 2, · · · ,m.

(4)

wherec5 is scaling constant parameter.

Fig. 8. Inside boundary forces on graph vertices.

Now we consider the triangular active area bounded by vec-tor vp(i+ 1)v1p(i+ 1) vectorvp(i+ 1)v2p(i+ 1) in Fig. 8.If the graph vertexvG(j) falls in this active area, we replacede(i) with distance from the graph vertexvG(j) to the nearestboundary vertexvp(i+ 1), using:

de(i) = |vp(i+ 1)vG(j)| (5)

For graph vertices that are not within the boundary, weassign a force towards the interior of the boundary to pullthem inside. The mechanism to assign outside boundary forceswithin each boundary edges active area is exactly the sameas discussed in previous section. This is also the case withmultiple boundaries where the interior boundaries have outsideactive areas. For each boundary edge, we have an inside activearea and an outside active area as illustrated in Fig. 9. For edge

Page 7: Graph Layout with Versatile Boundary Constraintspang/261/f15/misc/yani.pdf · 2019-06-02 · There are many interactive constraint-based graph layout systems in existence today. However,

7

Fig. 9. Outside boundary forces on graph vertices.

ep(i − 1) from vp(i) to vp(i − 1), the active area consists ofAi and the triangular gap betweenAi−1 andAi.

Note that outside graph vertices that are further away willhavestrongerboundary force acting on them, so the outsideboundary forcefBp is defined as:

fBp(vG(j), ep(i)) = c5 · de(i) ·ver(i)

|ver(i)|i = 1, 2, · · · , n, j = 1, 2, · · · ,m.

(6)

wherec5 is scaling constant parameter. By iterating throughall the boundary edges, the total boundary forces for vertexvG(j) from q boundary edges will be

∑q

p=1fBp(vG(j)). By

iterating through all the boundary edges in each boundaryBp,the total boundary force for vertexvG(j) from q boundaryedges will be

∑q

p=1

∑n

i=1fBp(vG(j), ep(i)).

D. Modified Force Components

Here we modify the conventional spring and repulsive forcesin order to combine with our boundary forces. We utilize theknowledge of the size of the graph and the size of the activearea to scale the forces appropriately to achieve a uniformdistribution of graph vertices.

1) Spring Force: Given a graphG, each vertex is placedin some initial random layout with coordinatesPi(x, y). Oncereleased, the spring forces act to move the system to a minimalenergy state. We use the logarithmic strength springs andmodify Equation(1) to:

fs(vG(i), vG(j)) = c1 ·α

β· log

(

|vG(i)vG(j)|c2

)

vG(i)vG(j)

|vG(i)vG(j)|i, j = 1, 2, · · · , n and i 6= j

(7)

α is the number of vertices in the graph.β is the totalactive area. Togetherα/β represents the average density ofvertices within the active area. This modification of Equation(1) allows the attractive spring forces to scale with the layoutdensity.

2) Repulsive Force:Equation(2) is modified in a similarmanner to take into account graph density:

fr(vG(i), vG(j)) = c3 ·β

α· vG(i)vG(j)

|vG(i)vG(j)|3i, j = 1, 2, · · · , n

(8)

This time the force is inversely related to the densityα/β.3) Boundary Force:Equations(4) and (6) are also mod-

ified in a similar manner to take into account graph density.For graph vertices that are within the boundary:

fBp(vG(j), ep(i)) = c5 ·α

β· 1

de(i)· ver(i)

|ver(i)|(9)

And for graph vertices that are outside the boundary:

fBp(vG(j), ep(i)) = c5 ·α

β· de(i) · ver(i)

|ver(i)|i = 1, 2, · · · , n and j = 1, 2, · · · ,m.

(10)

E. Graph Drawing Algorithm

Our drawing algorithm includes three main parts: (1) com-pute the attractive spring force of each graph edge and therepulsive gravitational force for each pair of graph vertices;(2) compute boundary forces for each vertex; then (3) add thethree different kinds of forces together. At each iteration, makea step towards the direction where the total force is pointingfor each vertex, and draw the updated graph.

V. I MPLEMENTATION AND TESTING TOOLS

A. Implementation

We developed a prototype using Matlab and its graphiclibrary. Tests were ran on an Intel Corei5 3GHz PC with8GBof memory running Windows7. Processing2.0 was used torealize the interactive part with users.

B. Synthetic Graphs

For testing purposes, we created a synthetic graph genera-tion program. Input to this program is the number of graphvertices and edges. The vertices are assigned an initial randomposition, while pairs of vertices are connected randomly usinguniform sampling of the vertices with replacement.

In Fig. 10, we show the initial random layout of a graphwhich has13 graph vertices and5 boundary vertices. Coordi-nates of the graph vertices are randomly generated while theboundary is user-defined. Red boundary vertices are connectedto form the boundary. Blue graph vertices scattered randomlyhave black arrows representing the total force and directionacting on them after each iteration. After150 iterations, we cansee the graph is indeed totally within the predefined boundaryin Fig. 11.

Page 8: Graph Layout with Versatile Boundary Constraintspang/261/f15/misc/yani.pdf · 2019-06-02 · There are many interactive constraint-based graph layout systems in existence today. However,

8

−4 −2 0 2 4 6−5

−4

−3

−2

−1

0

1

2

3

4

5

x position

y po

sitio

nBoundary constraints in force−directed graph layout

Fig. 10. Initial layout of graph.

−6 −4 −2 0 2 4 6−5

−4

−3

−2

−1

0

1

2

3

4

5

x position

y po

sitio

n

Boundary constraints in force−directed graph layout

Fig. 11. After150 iterations.

VI. RESULTS AND ANALYSIS

In this section, we apply our boundary constraints to severalgraph datasets using both synthetic graphs and publicly avail-able graph datasets. First we demonstrate how the graph layoutchanges with different boundary constraints. Then we ran iton different scales of graph data. Lastly, we show some visualresults of arbitrarily shaped boundaries and dynamic responseto altering the boundary during the graph layout process.

A. Experimental Results for Different Boundary Force Func-tions

We know the boundary forces depends on the distance fromthe graph vertex to the boundary edge. Here, we demonstratethe effects of changing the boundary force functions on thethe graph layout. Equation(9) specifies an inverse distancerelationship of boundary force on a graph vertex. Fig. 12illustrates how the positions of the graph vertices are affectedby changing the boundary force functions without changingthe boundary constraints. Note that graph edges are not drawnin these illustrations and convergence times vary as well. Inthis example, we are using the same graph with2000 verticesand4000 edges under the same set of parameters and the sameboundary of a regular pentagon.

In Fig. 12(a), we are using inverse ofd. By changing it toinverse of the logarithm ofd, the vertices are pushed furtheraway from the middle part of the boundary edges resultingin curved silhouettes as shown in Fig. 12(b). Since boundaryforce of inverse ofd2 is dropping much faster than inverse ofd, we see graph vertices are closer to the boundary as shownFig. 12(c). And since the boundary force of inverse of

√d is

dropping slower than inverse ofd we see the graph is furtherpushed further away from the boundary in Fig. 12(d).

B. Experimental Results for Different Scales of Graphs

Similar to conventional force-directed methods as discussedin Section 2, the complexity of our approach depends onnumber of vertices and edges in the graph [5]. Because thenumber of boundary vertices are much less than the numberof vertices in the graph, the running time of our approachremains at the same level. We ran some experiments to obtainsome actual running times. First, we fixed the ratio of verticesto edges in the graph, then increase the number of verticesand number of edges proportionately. The running times arelisted in Table I and the resultant layouts are shown in Fig. 13.Note that we are using the same topology of boundary as a

(a) 1/d (b) 1/ log d

(c) 1/d2 (d) 1/√d

Fig. 12. Different boundary force functions.

regular pentagon and inverse distance to the boundary edgeas the boundary force function for these experiments. We alsohide the edges of each graph in order to have a more clearview of the distribution of vertices.

TABLE IRUNNING TIME OF DATASETS THAT HAVE SAME RATIO OF VERTICES AND

EDGES

Number of verticesn Number of edgesm Average Runningtime t (seconds)

100 200 0.87500 1000 3.562000 4000 6.3310000 20000 53.91

We can see that the graph vertices are distributed evenlywithin each boundary. With increasing density of vertices,thegraph can reveal the shape of the boundary more clearly.

C. Visual Results for Boundaries with Different Topology

In this section, we define several convex and concaveboundary shapes. The visual results are listed in Fig. 14.We also defined multiple boundaries with layouts shown inFig. 15. Fig. 15(a) with one interior boundary and Fig. 15(b)with two interior boundaries.

Animation of both changing boundaries and graph layoutprocess are also an integral part of the visual feedback forthe users. Allowing users to adjust and manipulate boundaryvertices where the graph is to be constrained can be veryhelpful. Here, we took several screen shots of the graphlayout process with changing boundary shape. First we used aFacebook dataset of1589 vertices and2732 edges and changedthe layout from an initial square boundary constraint to atriangular boundary constraint (see Fig. 16). In Fig. 17, agraph inside a circular sun shape is rearranged to conformto a moon shaped boundary. Another example illustrated in

Page 9: Graph Layout with Versatile Boundary Constraintspang/261/f15/misc/yani.pdf · 2019-06-02 · There are many interactive constraint-based graph layout systems in existence today. However,

9

(a) n = 100 (b) n = 500

(b) n = 2000 (b) n = 10000

Fig. 13. Layout of datasets with have same ratio of vertices to edges.

Letter I Heart

Star Intersected

Fig. 14. Graph layout with different boundary shapes.

(a) Donut (b) Number8

Fig. 15. Different topologies with multiple boundaries.

Initial layout After animation

Fig. 16. Layouts from a Facebook user dataset.

Fig. 18 simulates graph vertices spreading out to fill an hourglass shape. At first, all the vertices in graph are at the top,asthe algorithm runs, they expand and spread out over this hourglass shape. Note that there are no downwards gravitationalforces modeled into the simulation.

VII. C ONCLUSION AND FUTURE WORK

This paper presented a novel way for manipulating and spec-ifying graph layout with the use of boundary constraints. Thisis incorporated within a force-directed simulation and does

Initial sun shape Changed to moon shape

Fig. 17. Layout changes from “sun” shape to “moon” shape.

Page 10: Graph Layout with Versatile Boundary Constraintspang/261/f15/misc/yani.pdf · 2019-06-02 · There are many interactive constraint-based graph layout systems in existence today. However,

10

Initial layout During process

During process Final layout

Fig. 18. Simulation with an hour glass shape.

not significantly increase the cost of graph layout. The force-directed simulator is self-contained and can be substituted witha more efficient implementation. The boundary constraints arequite general and can support arbitrary shapes including self-intersections and boundaries with different topologies.

The current work focuses on constraining graph vertices tolie within specified boundaries. No consideration is made forconstraining graph edges to lie within boundaries as well. Apossible extension is to constrain graph edges to lie withinboundaries as well.

REFERENCES

[1] Battista, Di Giuseppe, Eades Peter, Tamassia Roberto, and G. TollisIoannis. Algorithms for drawing graphs: an annotated bibliography.Computational Geometry4, 4(5):235–282, 1994.

[2] Battista, Di Giuseppe, Eades Peter, Tamassia Roberto, and G. TollisIoannis. Graph drawing: algorithms for the visualization of graphs.Prentice Hall PTR, 1998.

[3] Franois Bertault. A force-directed algorithm that preserves edge crossingproperties.Graph Drawing. Springer Berlin Heidelberg, 1731:351–358,1999.

[4] Koren David and Harel Yehuda. A fast multi-scale method for drawinglarge graphs.Journal of graph algorithms and applications, 6(3):179–202, 2002.

[5] Ron Davidson and David Harel. Drawing graphs nicely using simulatedannealing.ACM Transactions on Graphics (TOG), 15(4):301–331, 1996.

[6] Edmund Dengler, Mark Friedell, and Joe Marks. Constraint-drivendiagram layout. In Visual Languages,1993., Proceedings1993 IEEESymposium on, pages 330–335, 1993.

[7] Josep Dıaz, Jordi Petit, and Maria Serna. A survey of graph lay-out problems. ACM Comput. Surv., 34(3):313–356, September 2002.http://doi.acm.org/10.1145/568522.568523.

[8] Tim Dwyer, Kim Marriott, and Michael Wybrow. Topology preservingconstrained graph layout.Graph Drawing. Springer Berlin/Heidelberg,5417:230–241, 2009.

[9] Peter Eades. A heuristic for graph drawing.Congressus numerantium,42:146–160, 1984.

[10] W. Randolph Franklin. PNPOLY, 2014.http://www.ecse.rpi.edu/˜ wrf/Research/ShortNotes/pnpoly.html.

[11] Arne Frick, Andreas Ludwig, and Heiko Mehldau. A fastadaptive layout algorithm for undirected graphs. InProceed-ings of the DIMACS International Workshop on Graph Drawing,GD ’94, pages 388–403, London, UK, UK, 1995. Springer-Verlag.http://dl.acm.org/citation.cfm?id=647546.730941.

[12] Fruchterman, Thomas MJ, and Edward M Reingold. Graph draw-ing by force-directed placement.Software: Practice and experience,21(11):1129–1164, 1991.

[13] Stefan Hachul and Michael Junger. Drawing large graphs with apotential-field-based multilevel algorithm.Graph Drawing. SpringerBerlin Heidelberg, 3383:285–295, 2005.

[14] Weiqing He and Kim Marriott. Constrained graph layout.In Proceedings of the Symposium on Graph Drawing, GD’96, pages 217–232, London, UK, UK, 1997. Springer-Verlag.http://dl.acm.org/citation.cfm?id=647548.728749.

[15] Herman, Ivan, Guy Melanon, and Marshall M. Scott. Graphvisualizationand navigation in information visualization: A survey. visualizationand computer graphics.Visualization and Computer Graphics, IEEETransactions on, 6(1):24–43, 2000.

[16] Yifan Hu. Efficient, high-quality force-directed graph drawing. Mathe-matica Journal, 10(1):37–71, 2005.

[17] Tomihisa. Kamada. Visualizing abstract objects and relations. WorldScientific Publishing Company, 1989.

[18] Tomihisa Kamada and Satoru Kawai. An algorithm for drawing generalundirected graphs.Information processing letters, 31(1):7–15, 1989.

[19] Thomas Kamps, Joerg Kleinz, and John Read. Constraint-based spring-model algorithm for graph layout. InProceedings of the Symposiumon Graph Drawing, GD ’95, pages 349–360, London, UK, UK, 1996.Springer-Verlag. http://dl.acm.org/citation.cfm?id=647547.728580.

[20] Stephen Kobourov. Spring embedders and force directedgraph drawingalgorithms, 2012. http://arxiv.org/abs/1201.3011.

[21] Chun-Cheng Lin, Yi-Yi Lee, and Hsu-Chun Yen. Mental mappreserv-ing graph drawing using simulated annealing.Information Sciences,181(19):4253–4272, 2011.

[22] Kathy Ryall, Joe Marks, and Stuart Shieber. An interactive constraint-based system for drawing graphs.In Proceedings of the10th annualACM symposium on User interface software and technology, pages 97–104, 1997.

[23] Kozo Sugiyama and Kazuo Misue. Graph drawing by the magneticspring model.Journal of Visual Languages and Computing, 6(3):217–237, 1995.

[24] Kozo Sugiyama and Kazuo Misue. A simple and unified method fordrawing graphs: Magnetic-spring algorithm.Proceedings of GraphDrawing, GD94, 894:364–375, 1995.

[25] Roberto Tamassia. Constraints in graph drawing algorithms.Constraints,3(1):87–120, 1998.

[26] Christian Tominski, James Abello, and Heidrun Schumann. CGVan interactive graph visualization system.Computers and Graphics,33(6):660–678, 2009.

[27] Christian Tominski, Stefan Gladisch, Ulrike Kister, Raimund Dachselt,and Heidrun Schumann. A Survey on Interactive Lenses in Visualization.In R. Borgo, R. Maciejewski, and I. Viola, editors,EuroVis - STARs. TheEurographics Association, 2014.

[28] W. T. Tutte. How to draw a graph. Proceedings of the LondonMathematical Society, 13:743–768, 1963.

[29] Chris Walshaw. A multilevel algorithm for force-directed graph drawing.Graph Drawing. Springer Berlin Heidelberg, 1984:171–182, 2001.