510 likes | 522 Views
Chapter 5. Flow and Orthogonal Drawings. Nimrod Milo and Ilan Orlov. Final Example:. Goal:. Efficiently drawing of orthogonal graphs. Quality of a draw:. Minimal number of bends. 9 bends. 6 bends. Bend angle. Vertex angle. Every edge considered as two directed edges !!!.
E N D
Chapter 5 Flow and Orthogonal Drawings Nimrod Milo and Ilan Orlov
Goal: Efficiently drawing oforthogonal graphs
Quality of a draw: Minimal number of bends 9 bends 6 bends
Bendangle Vertex angle Every edge considered as two directed edges !!! Notations: Γ Orthogonal graph G Original graph
Lemma 1: In a planner orthogonal drawing, the sum of the measures around a vertex is equal to 2Π
Lemma 2.1: For each internal face of a planar orthogonal drawing. The sum of the measures of the vertex-angels and bend-angles insidef is equal to Π(p-2) where p is the number of such angels.
Lemma 2.2: For each external face of a planar orthogonal drawing. The sum of the measures of the vertex-angels and bend-angles insidef is equal to Π(p+2) where p is the number of such angels
Notations: a(f)– number of vertex-angles inf Counterclockwise edge with respect to face f f - face D(f) - Counterclockwise edge inside the face f
Notations: α(u→v) ·Π/2 The angle at vertex uformed byedge (uv) and the nextcounterclockwise around u
Notations: β(u→v) number of bends along(u→v) With theΠ/2angle on the left hand side.
Notations: α = ? β = ?
1 ≤α≤ 4 0 ≤ β 4
Flow Network Model A flow network N for a digraph G=(V,E) defined such that: • Each source v has a production σ(v). • Each sink u has a consume rate σ(u). • Total production = total consumption • For each edge (u,v) in E: • λ(u,v) – a lower bound of flow • μ(u,v) - Capacity of flow • χ(u,v) – Cost per unit of flow • A flow ϕ (ϕ: IN → IN) in Network N defined such that: • for each (u,v) in E : • λ(u,v) ≤ ϕ(u,v) ≤ μ(u,v) • The Cost of flow ϕ = ∑ϕ(u,v)∙ χ(u,v) • The objective is a Minimum cost of flow
Building network from graph • One unit of flow = П/2 • The nodes of N are the vertices and faces of G • A vertex-node v in V(N) produced flow σ(v)=4 • A face-node f in V(N) consumes flow • σ (f)= 2∙a (f) – 4 if f is internal face • σ (f)= 2∙a (f) + 4 if f is external face
Building network from graph • For each directed edge (u,v) in E with faces f, g on its left and right respectively we define to edges in E(N): • For edge (u,f): λ(u,f) = 1, μ(u,f) = 4 and χ(u,f)=0 (figure a) • For edge (f,g): λ(f,g) = 0, μ(f,g) = +∞ and χ(f,g )=1 (figure b)
u f v Building network from graph (Contd.) Lemma 3: Let G an embedded planar graph with n vertices. The flow Network N built from G has O(n) nodes and edges, And can be built in O(n) time. 1 1 π u 2 1 1 1 (u,v) Theorem 1:: Let G an embedded planar graph and N be the flow Network built from G. for the edge (u,v), let (u,f) and (f,g) be the associated edges in N: • ϕ(u,f) = α(u,v) • ϕ(f,g) = β(u,v)
Orthogonalize (algorithm 5.1) Input: planar Graph G with n vertices (Maximum degree of 4) The algorithm: • Construct the flow Network N from G • Compute Flow of minimum cost for N. • Compute the Orthogonal representation of G associated with the minimum cost flow. Output: orthogonal represntation of G with minimum number of bends Time Complexity: O(n²*log n) Space Complexity: O(n)
Compacting of Orthogonal Representation • Goal: • Assign integer length to the segments • No crossing, no overlaps • Minimum area, fast algorithm • – our case • area: O((n+b)2) b – no. bends • time: O((n+b)) First, assumerectangular faces !!
Rectangular faces • Each internal face has the shape of a rectangle • in the orthogonal representation H • H has at most 4 bends, placed at the corner of the external face. • Edge of G = edge of the H, excepts possibly for eight segments on the external face
For each edge set Minimum flow = 1 Cost =1
Run algorithm for finding flow with minimal cost flow = 1 flow = 2 flow = 3
Setting: edge length = Flow on the corresponding edge in the flow network
For each edge set Minimum flow = 1 Cost =1
flow = 1 flow = 2 flow = 3
Setting: edge length = Flow on the corresponding edge in the flow network
Combining the new vertical and horizontal lengths Running time: O(n7/4 logn)
Different compaction algorithm • Linear time • Minimizes the height, width, area of the drawing • Does not guarantee the minimum total edge length
Different compaction algorithm 1. Replacing bends with fictitious vertices 2. Orienting the horizontal edges from left to right 3. Contracting maximal paths of vertical edges to a vertex
compaction algorithm based on s-t-graph compaction algorithm We get a planer s-t-graph. Denote it as H*hor. Using same process we get H*ver. Assign unit weights to the edges to both s-t-graphs’ edges
Compute optimal weighted topological numbering X and Y As in previous lesson
General orthogonal representations • Add an isolated vertex 2. Insert a vertex along an edge H 3. Add an edge H’ G H H’ H’compactH’compact_without_extra edges/vertices
Final Theorem 5.4: Given an embedded planar graph G with n vertices of degree at most 4, and an orthogonal representation H of G with b bends, a planar orthogonal drawing of G with integer coordinates and areaO( (n+b)2 ) can be constructed in O(n+b)time.
Optimal-Orthogonal (algorithm 5.4) Input: planar Graph G with n vertices (Maximum degree of 4) The algorithm: • H ← Orthogononalize on graph G. • Refine H into an orthogonal representation H’ with rectengular faces. • D’ ← Fast-Orthogonal-Compact(H’) • D ← D’ while ignoring all the fictious edges and vertices. Output: planar orthogonal grid drawing D of G with area O(n²) and minimum number of bends Time Complexity: O(n²*log n) Space Complexity: O(n)
Constrains We can easily modify algorithm 5.4 to include two types of constrains: • Vertex-angle constrains – by setting the lower / upper bound of α(u,v) • Bend Constrains – by setting the lower / upper bound of β(u,v)
Minimizing number of bends Locally For a face-angle or a vertex angle we Define: π/2 – inflex π - flat 3π/2 - reflex For a given orthogonal representation Γ we define a curve C as an Elementary Transformation If the curve C intersect Γ only in inflex, flat or reflex angles. For each vertex traversed by Curve C the transformation subtract π/2 from the angle C enters, and adds π/2 to the angle where C exit.
For a Curve C we define flat(C),inflex(C),reflex(C) as the number of flat, inflex and reflex angles in C respectively Δ(C) = flat(C) + inflex(C) – reflex(C)
Theorem 5.6: an Orthogonal representation Γ has the minimum Numbers of bend iff for every cycle C in ΓΔ(C) ≥ 0 The proof of Theorem 5.6 is based on looking in the flow network Corresponding with Γ and flow in the cycle C. the result is that the flow can’t be a negative number.