the mathematics of force- directed placement simulating graphs as physical systems to assist in...

17
The Mathematics of The Mathematics of Force-Directed Force-Directed Placement Placement Simulating Graphs as Physical Simulating Graphs as Physical Systems Systems To Assist in Computer Chip Layout To Assist in Computer Chip Layout By Jamey Lewis, St. Michael’s College

Upload: cayla-wadhams

Post on 15-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

The Mathematics of Force-The Mathematics of Force-Directed PlacementDirected Placement

Simulating Graphs as Physical SystemsSimulating Graphs as Physical Systems

To Assist in Computer Chip LayoutTo Assist in Computer Chip Layout

By Jamey Lewis,St. Michael’s College

How do we convert…How do we convert…

……this…this…

… … into this?into this?

The ProblemThe Problem

We have a graph of nodes and edges (gates and We have a graph of nodes and edges (gates and wires in the computer chip).wires in the computer chip).

We need to find a good layout We need to find a good layout for the graph that provides a for the graph that provides a geometric representation of its geometric representation of its components and makes graph components and makes graph symmetry clearly visible.symmetry clearly visible.

In industry there may be In industry there may be constraints on the size of the constraints on the size of the components, but they may components, but they may also simply need to be far also simply need to be far enough apart to distinguish.enough apart to distinguish.

The SolutionThe Solution

Simulate the graph or network as a physical model Simulate the graph or network as a physical model (masses and springs, for example) and subject it to (masses and springs, for example) and subject it to physical forces.physical forces.

The unnecessarily-long edges The unnecessarily-long edges will be the most tense, and will will be the most tense, and will try to contract the most.try to contract the most.

When the nodes and edges When the nodes and edges have pushed and pulled have pushed and pulled themselves to equilibrium, we themselves to equilibrium, we will have a geometric will have a geometric representation of the graph in representation of the graph in the plane.the plane.

The Spring EmbedderThe Spring Embedder

A model of masses and springs, corresponding to nodes A model of masses and springs, corresponding to nodes and edges on a graph, is called a Spring Embedder.and edges on a graph, is called a Spring Embedder.

Spring forces exist between nodes and may attract or Spring forces exist between nodes and may attract or repel depending on how contracted they are, and on how repel depending on how contracted they are, and on how contracted they want to be (desired/ideal length).contracted they want to be (desired/ideal length).

Electrical forces may exist to repel nodes from one Electrical forces may exist to repel nodes from one another, to keep them as far apart as constraints dictate, if another, to keep them as far apart as constraints dictate, if spring repulsion is insufficient.spring repulsion is insufficient.

The Spring ForceThe Spring Force

The x-component of the The x-component of the Spring forceSpring force equation on vertex v. equation on vertex v.

The y-component equation mirrors this one.The y-component equation mirrors this one.

The force is applied to v by all springs (edges) between v The force is applied to v by all springs (edges) between v and another vertex.and another vertex.

kk(1)(1) : the stiffness of the spring between the two vertices: the stiffness of the spring between the two vertices LL : the resting length of the spring : the resting length of the spring d(pd(p11,p,p22)) : the linear distance between the two vertices : the linear distance between the two vertices

xx : the x-coordinate of a vertex’ position : the x-coordinate of a vertex’ position

(1)

( , )

( ( , ) )( , )v u

uv u v uvu v E u v

x xk d p p

d p p

The Repulsive ForceThe Repulsive Force

The x-component of the The x-component of the Repulsive forceRepulsive force equation on vertex v. equation on vertex v.

The y-component equation mirrors this one. The y-component equation mirrors this one.

The force is applied to v by all other vertices (perhaps limited The force is applied to v by all other vertices (perhaps limited to merely those within a specific effective range).to merely those within a specific effective range).

kk(2)(2) : electrical repulsion constant between two vertices: electrical repulsion constant between two vertices d(pd(p11,p,p22)) : the linear distance between the two vertices : the linear distance between the two vertices

xx : the x-coordinate of a vertex’ position : the x-coordinate of a vertex’ position

(2)

2( , ) ( , )( ) ( , )

u v

uv v u

u v VxV u vd p p

k x x

d p p

An ExampleAn Example

Concerning the Barycentric ModelConcerning the Barycentric Model Some Spring Embedders use a Gravitational force Some Spring Embedders use a Gravitational force

to attract all nodes toward the graph’s Barycenter to attract all nodes toward the graph’s Barycenter (the average of all node positions) in order to (the average of all node positions) in order to show symmetry more clearly and keep loosely-show symmetry more clearly and keep loosely-connected groups of nodes from drifting.connected groups of nodes from drifting.

Others simulate this by creating at least 3 Fixed Others simulate this by creating at least 3 Fixed vertices on the edges of the graph and giving all vertices on the edges of the graph and giving all edges an ideal length of 0, causing them to want edges an ideal length of 0, causing them to want to contract as long as they are able, counteracted to contract as long as they are able, counteracted only by the attraction from the fixed vertices.only by the attraction from the fixed vertices.

My ImplementationMy Implementation

Instead of directly implementing simulated Gravity, Instead of directly implementing simulated Gravity, I chose to use the method of setting some but not I chose to use the method of setting some but not all Ideal Edge Lengths to 0.all Ideal Edge Lengths to 0.

This results in a graph that is sufficiently flexible to This results in a graph that is sufficiently flexible to show off geometry, yet not unnecessarily bent show off geometry, yet not unnecessarily bent towards the middle to produce a circular formation.towards the middle to produce a circular formation.

However, I also retained the Repulsive forces that However, I also retained the Repulsive forces that are not present in the 2are not present in the 2ndnd method, so that fixed method, so that fixed points would not be a requirement.points would not be a requirement.

A Problem: OscillationA Problem: Oscillation One of the problems of Spring Embedder One of the problems of Spring Embedder

implementation is of Oscillation, that is, when nodes implementation is of Oscillation, that is, when nodes move back and forth repetitively without ever stabilizing.move back and forth repetitively without ever stabilizing.

This happens because the application of forces in a This happens because the application of forces in a computer program occurs in steps and not continuously, computer program occurs in steps and not continuously, and moving vertices are given the chance to move past and moving vertices are given the chance to move past their stable destinations in a single step, forcing them to their stable destinations in a single step, forcing them to move back and forth.move back and forth.

A form of oscillation that also occurs is Rotation, when A form of oscillation that also occurs is Rotation, when vertices continuously move in a circle.vertices continuously move in a circle.

The Solution: TemperatureThe Solution: Temperature

A solution to this problem is to implement a A solution to this problem is to implement a “Temperature” for each vertex, acting as a factor for its “Temperature” for each vertex, acting as a factor for its movement. movement. Hot = fastHot = fast, , cold = slowcold = slow..

When traveling continuously in the same direction, a When traveling continuously in the same direction, a Vertex’ temperature will increase and it will speed up. Vertex’ temperature will increase and it will speed up. When Oscillation or Rotation are detected, the Vertex’ When Oscillation or Rotation are detected, the Vertex’ temperature will drop, and it will slow down.temperature will drop, and it will slow down.

Oscillation and TemperatureOscillation and Temperature

The direction of the impulse of vertex v. After adjustment The direction of the impulse of vertex v. After adjustment based on which quadrant the movement is in, this can be based on which quadrant the movement is in, this can be used to determine if the new direction is over 90 degrees used to determine if the new direction is over 90 degrees different from the old direction.different from the old direction.

θ θ : the direction of the impulse of vertex v: the direction of the impulse of vertex v Δ Δ : the change in x or y position of vertex v: the change in x or y position of vertex v

arctan( )v

v

y

x

Oscillation and TemperatureOscillation and Temperature

100v

v v

Tx x

The x-component of the movement of vertex v as affected The x-component of the movement of vertex v as affected by Temperature.by Temperature.

The y-component equation mirrors this one.The y-component equation mirrors this one.

ΔΔ : the change in x position of vertex v as a result of forces: the change in x position of vertex v as a result of forces TT : the Temperature variable of vertex v, ranging from 0-100 : the Temperature variable of vertex v, ranging from 0-100

ExampleExample

One More ExampleOne More Example

ENDENDThanks for listening!Thanks for listening!