Title: Flow and Orthogonal
1Chapter 5
Flow and Orthogonal Drawings
Nimrod Milo and Ilan Orlov
2Final Example
3Goal
Efficiently drawing of orthogonal graphs
4Quality of a draw
Minimal number of bends
9 bends
6 bends
5Every edge considered as two directed edges !!!
Notations
G Orthogonal graph
G Original graph
6Lemma 1
In a planner orthogonal drawing, the sum of the
measures around a vertex is equal to 2?
7Lemma 2.1
For each internal face of a planar orthogonal
drawing. The sum of the measures of the
vertex-angels and bend-angles inside f is equal
to ?(p-2) where p is the number of such angels.
8Lemma 2.2
For each external face of a planar orthogonal
drawing. The sum of the measures of the
vertex-angels and bend-angles inside f is equal
to ?(p2) where p is the number of such angels
9Notations
a(f) number of vertex-angles in f
Counterclockwise edge with respect to face f
f - face
D(f) - Counterclockwise edge inside the face f
10Notations
a(u?v) ??/2 The angle at vertex u formed by edge
(u?v) and the next counterclockwise around u
11Notations
ß(u?v) number of bends along (u?v) With the
?/2 angle on the left hand side.
12Notations
a ?
ß ?
13 a
1
4
ß
0
4
14(No Transcript)
15(No Transcript)
16Flow Network Model
A flow network N for a digraph G(V,E) defined
such that
- Each source v has a production s(v).
- Each sink u has a consume rate s(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
17Building 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 s(v)4
- A face-node f in V(N) consumes flow
- s (f) 2a (f) 4 if f is internal face
- s (f) 2a (f) 4 if f is external face
18Building 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) 8 and
?(f,g )1 (figure b)
19Building 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.
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
20Orthogonalize (algorithm 5.1)
Input planar Graph G with n vertices (Maximum
degree of 4)
Output orthogonal represntation of G with
minimum number of bends
Time Complexity O(n²log n) Space Complexity
O(n)
- 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.
21Compacting of Orthogonal Representation
- Goal
- Assign integer length to the segments
- No crossing, no overlaps
- Minimum area, fast algorithm
- our case
- area O((nb)2) b no. bends
- time O((nb))
First, assume rectangular faces !!
22Rectangular 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
23Tidy-Rectangle-Compact algorithm
24(No Transcript)
25For each edge set Minimum flow 1 Cost 1
26Run algorithm for finding flow with minimal cost
flow 1
flow 2
flow 3
27Setting edge length Flow on the
corresponding edge in the flow network
28(No Transcript)
29(No Transcript)
30For each edge set Minimum flow 1 Cost 1
31flow 1
flow 2
flow 3
32Setting edge length Flow on the
corresponding edge in the flow network
33Combining the new vertical and horizontal lengths
Running time O(n7/4 logn)
34Running time O(n7/4 logn)
35Different compaction algorithm
- Linear time
- Minimizes the height, width, area of the drawing
- Does not guarantee the minimum total edge length
36Different 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
37compaction algorithm based on s-t-graph
compaction algorithm
We get a planer s-t-graph.
Denote it as Hhor.
Using same process we get Hver.
Assign unit weights to the edges to both
s-t-graphs edges
38Compute optimal weighted topological numbering X
and Y As in previous lesson
39Running time O(n)
40General orthogonal representations
- Add an isolated vertex
2. Insert a vertex along an edge
H
3. Add an edge
H
G ? H ? H ? Hcompact? Hcompact_without_extra
edges/vertices
41Final 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 area O( (nb)2 ) can be constructed in O(nb)
time.
42Optimal-Orthogonal (algorithm 5.4)
Input planar Graph G with n vertices (Maximum
degree of 4)
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)
- 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.
43Constrains
- We can easily modify algorithm 5.4 to include two
types of constrains
- Vertex-angle constrains by setting the lower /
upper bound of a(u,v)
- Bend Constrains by setting the lower / upper
bound of ß(u,v)
44Minimizing number of bends Locally
45Minimizing number of bends Locally
For a face-angle or a vertex angle we
Define p/2 inflex p - flat 3p/2 - reflex
For a given orthogonal representation G we define
a curve C as an Elementary Transformation If the
curve C intersect G only in inflex, flat or
reflex angles.
For each vertex traversed by Curve C the
transformation subtract p/2 from the angle C
enters, and adds p/2 to the angle where C exit.
46For 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)
47Theorem 5.6 an Orthogonal representation G has
the minimum Numbers of bend iff for every cycle
C in G ?(C) 0
The proof of Theorem 5.6 is based on looking in
the flow network Corresponding with G and flow
in the cycle C. the result is that the flow
cant be a negative number.
48Elementary Transformation
49Elementary Transformation
50Elementary Transformation
51Elementary Transformations example