Presentation is loading. Please wait.

Presentation is loading. Please wait.

I NTRODUCTION TO G RAPH DRAWING Fall 2010 Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G. 1998 Graph Drawing: Algorithms for the Visualization.

Similar presentations


Presentation on theme: "I NTRODUCTION TO G RAPH DRAWING Fall 2010 Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G. 1998 Graph Drawing: Algorithms for the Visualization."— Presentation transcript:

1 I NTRODUCTION TO G RAPH DRAWING Fall 2010 Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G. 1998 Graph Drawing: Algorithms for the Visualization of Graphs. 1st. Prentice Hall PTR.

2 F ORCE D IRECTED METHODS

3 F ORCE -D IRECTED M ETHODS Use a physical analogy to draw graphs View a graph as a system of objects with forces acting between them. Goal: Find a configuration of the objects or vertices with locally minimal energy Find a position for each object such that the sum of the forces on each object is zero. http://en.wikipedia.org/wiki/Force-based_algorithms_%28graph_drawing%29

4 E XAMPLE a)A graph where vertices have been replaced with electrically charged particles that repel each other and edges have been replaced by springs that connect particles and attract them. b)An equilibrium configuration, were the sum of the forces on each particle is zero. c)The interpretation of (b) as a straight-line drawing of the graph (a) (b) (c)

5 F ORCE -D IRECTED M ETHODS Vertex: Object of the system; Interacting with each other based on “some” force(s). Edge: A different type of object; Not interacting with each other; Add new force(s) to vertex object. Equilibrium configuration: the sum of forces on each vertex object is zero

6

7 D IFFERENT FD METHODS The model: a forced system defined by the vertices and edges which provides a physical model for the graph. The algorithm: the technique for finding a balance state of the force system, that is the position for each vertex such that the total force on every vertex is zero.

8 T HEY ARE POPULAR The physical analogy makes them easy to understand and easy to code. The result can be good.!!! They have been in use before applications in graph visualization, for pure mathematics and layout of printed circuit boards

9 S OME WELL - KNOWN FD METHODS Springs and electrical forces The Barycenter method Forces simulating graph theoretic distances Magnetic fields

10 S PRING AND ELECTRICAL FORCES Vertex: Electrically charged particles; Repel each other. Edge: Spring that connect particles; Attraction force when longer than the natural length; Repulsion force when shorter than the natural length. The model The algorithm

11 F ORCES ON EACH VERTEX The force on each vertex is the combination of spring forces and electrical forces: f follows the Hook’s low: it is proportional to the difference between the distance between u and v and the zero-energy length of the spring. g follows the inverse square low.

12 The x component of F(v): d ( p u, p v ) : Euclidian distance between p u and p v p v =( x v, y v ): the position of vertex v l uv : the natural (zero energy) length of the spring between u and v. (What if the spring has the length l uv ? ) :the stiffness of the spring between u and v :the strength of the electrical repulsion between u and v.

13 A IMS TO SATISFY AESTHETICS : The spring force between adjacent vertices is aimed to ensure that the distance between adjacent vertices u and v is approximately equal l uv. The electrical force aims to ensure that vertices should not be too close together One may choose parameters l uv, k (1) uv and k (2) uv to customize the appearance e of the drawing or to express semantic features of the graph.

14 G OAL OF THE ALGORITHM Find an equilibrium configuration of the forces that are on each vertex. Find a drawing in which the total force F(v) for each vertex v is zero. Find a drawing in which the energy is locally minimal with respect to the vertex positions.

15 H OW THIS A LGORITHM W ORK ? Regardless of the exact nature of the forces in the virtual physical system, force directed algorithms. Compute a locally minimum energy layout of the nodes. This is usually achieved by computing the forces on each node and iterating the system in discrete time steps. The forces are applied to each node and the positions are updated accordingly

16 S TEPS Vertices are initially placed at random locations At each iteration the force F(v) on each vertex v is computed Each vertex v is moved in the direction of F(v) by a small amount proportional to magnitude of F(v). http://en.wikipedia.org/wiki/Force-based_algorithms_%28graph_drawing%29

17 17 Layout Energy Initial (random) layoutFinal (nice) layoutIteration 1:Iteration 2:Iteration 3:Iteration 4:Iteration 5:Iteration 6:Iteration 7:Iteration 8:Iteration 9: FD G RAPH D RAWING Graph drawing = Energy minimization Hence, the drawing algorithm is an iterative optimization process

18 A DVANTAGES Relatively simple & easy to implement Good flexibility Smooth evolution of the drawing into the final configuration helps preserving the user’s mental map Can be extended to 3D Often able to display symmetries Works well in practice for small graphs with regular structure

19 D ISADVANTAGES Slow running time Results are acceptable, but not brilliant Few theoretical results on the quality of the drawings produced Difficult to extend to orthogonal & polyline drawings Limited constraint satisfaction capability

20 S CALING WITH L ARGE G RAPHS Traditional force-directed methods are limited to a few hundred nodes Problems when drawing large graphs: Visualization issue: not enough drawing area Cures: dynamic navigation, clustering, fish-eye view, hyperbolic space,… Algorithmic issue: convergence to a nice layout is too slow

21 2. B ARYCENTER M ETHOD Use springs with natural length 0, and attractive force proportional to the distance between vertices Pin down the vertices of the external face to form a given convex polygon (position constraint) Let the system go… The model The algorithm

22 A S A VARIATION OF THE PREVIOUS METHOD l uv = 0, k 1 u,v = 1, no electrical force 0 0 1

23 Partition V into two sets: fixed vertex (at least 3, nailed down) and free vertex To achieve equilibrium, choose p v so that F x (v) = 0 for all free vertices; Similarly, choose p v so that F y (v) = 0 for all free vertices. Therefore, Based on the definition of Barycenter: Where: deg(v) is the degree of v, N 0 (v): set of fixed neighbors of v ; N 1 (v): set of free neighbors of v.

24 The equations are linear. The number of equations and the number of unknown variables are both equal to the number of free vertices. Solving them equals to placing each free vertex at the barycenter of its neighbors. So the name ‘barycenter method’.

25 B ARYCENTER DRAW A LGORITHM Input: graph G=(V,E) Partition V=V 0 U V 1 (V 0 fixed vertices and V 1 free vertices) Strictly convex polygon P with |V 0 | vertices Output: A position p v for each vertex of V, such that the fixed vertices form a convex polygon P 1.Place each fixed vertex u in V 0 at a vertex of P and each free vertex in V 1 at the origin of P 2. Repeat For each free vertex v do 3. Until x v and y v converge for all free vertices v.

26 A N E XAMPLE OUTPUT OF THE ALGORITHM The energy of a drawing is the sum of the squares of the lengths of the edges.

27 F ORCE S IMULATING G RAPH T HEORETIC D ISTANCE Models graph theoretic distance with Euclidian distance. Let G=(V,E) be a connected graph and u,v in V, the Graph Theoretic Distance δ(u,v) of u and v is the number of edges on a shortest path between u and v The goal is to find a drawing in which, for each pair u,v of vertices, the Euclidian distance between u and v d(p u,p v ) is approximately proportional to δ(u,v) The system has the force proportional to: d(p u,p v )- δ(u,v) between vertices u and v. [Kamada Kawai 89] The model The algorithm

28 Potential energy in the spring between u and v : Kamada chooses Thus the energy in ( u,v ) is:

29 Energy in the whole drawing is the sum of these individual energies: The algorithm is looking for a position p v =(x v,y v ) for v to minimize η How?

30 H OW IT WORKS These equations are nonlinear, however, iterative approach can solve the equation At each step, a vertex is moved to a position that minimizes energy, while other vertices remain fixed Choose a vertex that has the largest force acting on it, that is

31 M AGNETIC F IELDS Variations: Some or all of the springs are magnetized There is a global magnetic field that acts on the spring Magnetic field can be used to control the orientation of edges Basic types of magnetic fields Parallel: all magnetic forces operate in the same direction Concentric: the force operates in concentric circles Radial: the forces operate radially outward from a point The model The algorithm [SM95]

32 The three basic magnetic fields can be combined encourage orthogonal edges with a combination of parallel forces in the horizontal & vertical directions The springs can be magnetized in two ways: Unidirectional: the spring tends to align with direction of the magnetic field Bidirectional: the spring tends to align with the magnetic field, but in either direction A spring may not be magnetized at all O PTIONS

33 The magnetic field induces a torsion or rotational force on the magnetic springs. For a unidirectionally magnetized spring representing ( u,v ), the force is proportional to: d(p u, p v )    Where: d(p u, p v ): Euclidean distance between p u and p v   : angle between the magnetic field and the line from p u to p v   and  are constant θ Unidirectional magnetic spring Direction of the magnetic field O PTIONS pupu pvpv

34 The magnetic forces are combined with the spring & electrical force Algorithm to find equilibrium: Vertices are positioned initially at random position and at each iteration the vertices move to positions with a lower energy Can handle directed graphs (unidirectional springs with one of the 3 fields) arcs point downward: downward parallel field Outward: radial field Counterclockwise: concentric field H OW IT WORKS

35 Can be applied to orthogonal drawings: combined vertical & horizontal field with bidirectional springs Applied with success to mixed graphs (graph with both directed & undirected edges)

36 T WO E XAMPLES Vertical magnetic field Vertical and horizontal magnetic field and

37 G ENERAL E NERGY F UNCTION Broaden the class of aesthetic criteria by including discrete energy function for example: The number of edge crossings The number of horizontal & vertical edges The number of bends in edges Solution: The linear combination of several types of energy: η i : a measure for an aesthetic criterion, may include spring, electrical or magnetic energy λ i : is a constant

38 Where: similar to electrical repulsion (vertices do not come too close together) r u, l u, t u, b u : Euclidean distance between vertex u and the four side lines of rectangular area (vertices do not come too close to the border of the screen) ensures that edges do not become too long η 4 : is the number of edge crossings in the drawing. E XAMPLE : ENERGY FUNCTION FOR STRAIGHT LINE DRAWINGS [ Davidson & Harel 96]

39 Flexibility of general energy function: allow variety of aesthetics by adjusting i [BBS97]: user can choose & adjust system parameters [Mendonca94]: how these coefficients can be automatically adjusted to user’s preference Main problem: computationally expensive to find a minimum energy state (very slow) simulated annealing [DH96]….. Genetic algorithm [BBS97]… Flexibility ensures popularity

40 [D AVIDSON & H AREL 96] SIMULATED ANNEALING Energy function takes into account vertex distribution, edge-lengths, and edge-crossings Given drawing region acts as wall Simulated annealing: flexible optimization technique Efficiency: very slow 30 nodes and 50 edges Able to deal with optimization problem in a discrete configuration space Aim: to minimize (or maximize) the cost function


Download ppt "I NTRODUCTION TO G RAPH DRAWING Fall 2010 Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G. 1998 Graph Drawing: Algorithms for the Visualization."

Similar presentations


Ads by Google