120 likes | 333 Views
Graph drawing Force directed methods. Network Algorithms 2005. Force directed methods. Method for arbitrary graphs Uses physical analogy: Force system Method to find equilibrium state Advantages: Relatively easy to understand and implement Often reasonably nice results.
E N D
Graph drawingForce directed methods Network Algorithms 2005 Netwerk Algorithms: Planar graphs
Force directed methods • Method for arbitrary graphs • Uses physical analogy: • Force system • Method to find equilibrium state • Advantages: • Relatively easy to understand and implement • Often reasonably nice results Netwerk Algorithms: Planar graphs
Springs and electrical forces method • Edges are springs • Vertices repel each other • Force on vertex: • fuvis force on spring • guv is repelling force Netwerk Algorithms: Planar graphs
Spring force • Assume some `wanted length’ of an edge luv. (E.g., 1.) • Spring wants to assume length luv; force is proportional to difference with luv. • Choose some stiffness of the spring kuv.’ • Force in x-direction is (y-direction similar): Netwerk Algorithms: Planar graphs
Repelling force • Vertices are repelling particles • Follow inverse square law • k’uvis strength of repulsion (choose some number, e.g., experimentally) • Repelling force of v in x-direction: Similar in y-direction Netwerk Algorithms: Planar graphs
Search for equilibrium • Position where all vertices have a force of 0 towards them (sum of spring and repelling forces) • Springs have lengths of edges go to desired length • Repelling has vertices not too close together Netwerk Algorithms: Planar graphs
Searching for equilibrium • Numerical techniques • Simple algorithm: • Take for each vertex a random position • Repeat: • Compute for each vertex its force • Move all vertices to new position depending on their forces Until in sufficient rest • Faster algorithms exist Netwerk Algorithms: Planar graphs
Barycenter method • Tutte, 1960 • Differences with force method • No repelling forces • luv = 0 • Stiffness is 1 • Vertices at exterior face get fixed positions Netwerk Algorithms: Planar graphs
Force on a vertex Where pu is the position of u on the plane If v is a free vertex Netwerk Algorithms: Planar graphs
Finding equilibrium • System of forces can be written as set of linear equations • Fast converging algorithms • For planar graphs, system can be solved in O(n1.5) time Netwerk Algorithms: Planar graphs
Barycenter draw pseudocode • Place all fixed vertices at corners of polygon around origin, and all free vertices on origin • Repeat • For each free vertex v do • x(v) = 1/degree(v) * S((u,v) in E) x(u) • y(v) = 1/degree(v) * S((u,v) in E) x(u) until sufficient convergence Netwerk Algorithms: Planar graphs
Theorem of Tutte • If G is a triconnected planar graph, then this method yields a planar drawing of G. • Assuming … • In practice, layers become smaller in the inside • Generalizations with more complicated forces sometimes also have this property • If G is not triconnected, then we can make it triconnected by adding edges Netwerk Algorithms: Planar graphs