370 likes | 550 Views
Introduction to Graph 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. Data flow analysis. Scheduling. Electrical networks. Database logic algorithm.
E N D
Introduction to Graph 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.
Data flow analysis Scheduling Electrical networks Database logic algorithm Divide and ConquerSeries-Parallel Digraphs
Series-Parallel Digraphs • Directed graph with a source and sink nodes or poles. sink source
The recursive definition of s-p digraph • An edge joining two vertices is a s-p digraph. (a) • Let G’ and G” be two s-p digraphs these two compositions of them also are s-p digraphs: • The series composition of G’ and G” is the digraph obtained identifying the sink of G’ with the source of G”. (b) • The parallel composition of G’ and G” is the digraph obtained by identifying the source of G’ with the source of G” and the sink of G’ with the sink of G”. (c)
Series composition of digraphs • Identifying the sink of one and the source of the other as one vertex sink sink sink source source source
Parallel composition of digraphs • Identifying as one vertex both their sources • Identifying as one vertex both their sinks sink sink sink source source source
Decomposition trees • A series-parallel digraphs is associated with a binary tree named decomposition tree or parse tree • There are three different kinds of nodes in this tree: S-nodes, P-nodes and Q-nodes.
The recursive definition of Decomposition trees • G is a single edge so T is a single Q-node Q
Decomposition trees • If G is a parallel composition of s-p digraphs: G1 and G2 , and T1 and T2 are their decomposition trees respectively, then T the decomposition tree of G has a root which is a P-node and two subtrees T1 and T2 P T1 T2
Decomposition trees • If G is a series composition of s-p digraph:G1 and G2 , the sink of G1 is identified with the source of G2 .And T1 and T2 are their decomposition trees respectively, then T the decomposition tree of G has a root which is a S-node and two subtrees T1 and T2 S T1 T2
Decomposition trees • The leaves of T are Q-nodes • The internal nodes are either S-nodes or P-nodes. • If a node has the same type as its parentit will be the right child • T is unique for G • If G has n nodes then T has O(n) leaves and O(n) nodes. (graph G is simple) • T can be created in O(n) time so will be assumed to be part of the input
P P P T2 S S T2 T1 T1 T1 S Q Q Q Q
P • The leaves of T are Q-nodes • The internal nodes are either S-nodes or P-nodes. • If a node has the same type as its parentit will be the right child • T is unique for G S P Q S S S Q Q Q Q S S Q Q S P Q S P S Q S Q Q Q Q Q Q
Components • Let C be a maximal path of same node type on T • Let u1 … ukchildren of C not on C • Component is the part of G associated with a subsequence ui … ujwhere 1 ≤ i ≤ j ≤ k • Component is closed when C is of S-nodes • Otherwise it is open
Closed component P S P Q S S S Q Q Q Q S S Q Q S P Q S P S Q S Q Q Q Q Q Q
E. Di Giacomo, Drawing series-parallel graphs on restricted integer 3D grids, in Proc. 11th International Symp. on Graph Drawing (GD ’03), vol. 2912 of Lecture Notes in Comput. Sci., Springer, 2004, pp. 238–246.
Looking for a drawing for s-p digraph • It has been proved that : there exist embedded s-p digraphs that any of their upward straight-line drawing that preserves embedding, requires exponential area. [ P.Bertolizza, R.F. Cohen, G.Di Battista, R. Tamassia and I.G. Tollis: “How to Draw a Series-Parallel Digraph”, InternatJ.Comput. Geom. Appl., 4, 385-402, 1994. ] [ A. Garg and R. Tamassia,:” Efficient Computation of Planar Straight-Line Upward Drawing”, In GD 93, (Proc. ALCOM Workshop on Graph Drawing.) 1993. ] • To have a drawing with polynomial area it is necessary to change the given embedding.
Right-pushed embedding • The edge (u,v) in G is transitive if there is another path from u to v other than (u,v). • Drawing transitive edge (u, v) on the right of all components with u and v poles
Δ-SP-Draw top side • Drawing inside a bounding triangle Δ(Γ) which is isosceles and right-angled. • Series composition: one above the other • Parallel – one to the right of the other bottom side base G1 G2 G2 G1
Δ-SP-Draw – base • If G is a single edge • Draw it as a vertical edge • Bounding triangle Δ(Γ) t G s
Δ-SP-Draw – series • If G is a series composition of G1 and G2 • Recursively draw Γ1 and Γ2 • Translate Γ2 so G2’s sink is on G1’s source • Extend bounding triangle Δ(Γ) accordingly G1 G2
Prescribed-region • (v, t) and (s, u) are rightmostedges on G1 • λv and λu are rays parallelto G1’s bounding triangle • G2 will be translated toanywhere on the right of λv, λu and k. k λv t v G2 u G1 s λu
Δ-SP-Draw – parallel • If G is a parallel composition of G1 and G2 • Recursively draw Γ1 and Γ2 • Translate Γ2 to the “prescribed-region” of G2(right of the dashes) • Extend bounding triangle Δ(Γ)accordingly • Move sources and sinks toupper and lower corners of Δ(Γ) G2 G1
P S S t Q Q Q S 3 2 Q Q 1 t” t’ s 1 3 2 s’ s”
Moving source and sink t 3 2 1 t” s t’ 1 3 2 s’ s”
Invariants • The drawing is contained inside the right angled triangle. • The source and sink are placed at the bottom and top corner of Δ(Γ) respectively. • For any vertex u adjacent to the source s of G, the wedge formed at u by rays with slopes -/2 and -/4 does not contain any vertex of G except s. • For any vertex v adjacent to the sink t of G, the wedge formed at v by rays with slopes /2 and /4 does not contain any vertex of G except t. t u s
Lemma 3.3 • Let u and v be neighbors of the sourceso (s, u) is left of (s, v) • Let λu and λv be rays of slope - /4from u and v • If invariant 3 holdsthen λu is below λv u v λv s λu
Lemma 3.3 – outcome • If G2 is placed to the right of G1 and above λuwhere (s, u) is the rightmost edge of s on G1 • Then no vertex of G2 is in the wedge limited by the –/4 ray from the neighbors of s • Hence if invariant 3 is held onG1 and G2 it is also held on G • Symmetrically invariant 4 can be proved u s
Therefore • Proving Invariants 3 and 4 guarantee thats and t can be moved as described in the algorithm without creating crossings. • Invariant 2 states that left cornerof Δ(Γ) is always empty,so G2’s left corner can beon the base of G1.
Area of the triangle • So the base of resulting triangle is equals the sum of bases of both triangles. • For a graph with n vertices the length of the base is 2n. • So the area needed is O(n2)
Calculating distances We’ll describe Γ by: b = length of the base b’ = vertical distance to λu b” = vertical distance to λv κ b’ λv t v b u s λu b’’
Parallel distances To describe parallel combinations we’ll use: Δx = horizontal distance fromΔ(Γ1) to Δ(Γ2) Δy = vertical distance frombottom ray of Δ(Γ1) toleft corner of Δ(Γ2) Δx Δy
Δ-SP-label input : decomposition tree T of G output : labeling b, b’, b’’ for each subtree of T if root = Q-node then b(T) = b’(T) = b’’(T) = 2 elseΔ-SP-label of T1 and T2 (the subtrees) if root = S-node then b(T) = b(T1) + b(T2) b’(T) = b(T1) b’’(T) = b(T2) else root = P-node then b(T) = b(T1) + b(T2)+2Δx if T2 is Q-node (transitive edge) then b’(T) = b’’(T) = b(T) else b’’(T) = b(T1) + 2Δx – Δy + b’’(T2) b’(T) = b’(T2) + Δy
Δ-SP-label • Δx can be 0 • Δy can be b’(T1) • The area needed is O(n2) • The algorithm runs in O(n)and needs O(n) space end of Series-Parallel Digraphs