0% found this document useful (0 votes)
24 views51 pages

04 Trees

The document discusses trees and graph representations. It defines trees as directed acyclic graphs with a single root node and paths from the root to all other nodes. Trees are useful for representing hierarchies. Common tree layouts include indentation, node-link diagrams, layered diagrams, and radial/circular layouts. The Reingold-Tilford algorithm positions child nodes under their parent for an aesthetic drawing.

Uploaded by

Ng Yiu Fai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views51 pages

04 Trees

The document discusses trees and graph representations. It defines trees as directed acyclic graphs with a single root node and paths from the root to all other nodes. Trees are useful for representing hierarchies. Common tree layouts include indentation, node-link diagrams, layered diagrams, and radial/circular layouts. The Reingold-Tilford algorithm positions child nodes under their parent for an aesthetic drawing.

Uploaded by

Ng Yiu Fai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Trees

COMP7507
Visualization & Visual Analytics
Graphs
• Graphs are best for representing relational
structures
– Relational database
– Object-oriented systems (class browsers)
– Data structure (compiler data structure)
– Real-time systems (state-transition diagrams)
– Virtual reality (scene graphs)
– Evolutionary trees, phylogenetic trees, genetic maps
– Social networks, citation networks
– Computer networks
– World wide web
– …

2
Graphs
• A graph G=(V, E) comprises a finite set V of vertices (or
nodes) and a set E of edges (or lines), with each edge being
an unordered pair (u, v) of vertices, u, v Î V.
• A directed graph consists of ordered pairs of vertices.

1 1

3 3
2 2

4 4

undirected graph directed graph

3
Graphs
• The degree of a vertex
= the number of edges incident to it
= the number of neighboring vertices.

1 in_deg(v3) = 2 1

deg(v3) = 3 out_deg(v3) = 1

3 3
2 2

4 4

undirected graph directed graph

4
Graphs
• A path is a sequence of edges connecting a
sequence of vertices
• A graph is connected if there is a path between
any two vertices.
1 1

3 3
2 2

4 4

connected graph disconnected graph


5
Graph Representation
1

3
2

Adjacency Matrix • Random access to edges


Target • O(n2) space
1 2 3 4
1 0 2 1 0
• Not a compact storage,
2 0 0 3 0
especially when the matrix is
Source
3 0 0 0 2
a sparse matrix (i.e., a graph
4 0 0 0 0
with only a few edges)
Matrix entries storing edge weights or labels 6
Graph Representation
1

3
2

Adjacency List Edge List • Storage


1 -> 2, 3 1, 2, 2
proportional to
2 -> 3 1, 3, 1 number of edges
3 -> 4 2, 3, 3
3, 4, 2
• However, only
support sequential
List the edges for each vertex Enumerates all edges access to edges
7
Graph Drawing
• There are many different ways of drawing a
graph. Danny Mary John
Venus Paul
Paul

John Danny Peter


Elvis
Ann
Mary Elvis Jack
Peter
Jack
Ann a planar graph
Venus

• Whether a drawing is good or not is subjective


and depends on perception.
8
Graph Drawing
Requirements
• Drawing conventions
– Rules specific to certain applications / professions
• Aesthetics
– Readability, layout
• Constraints

9
Drawing Conventions
• Straight-line drawing
• Polyline drawing
• Orthogonal drawing
• Planar drawing
• Grid drawing
• Upward drawing

10
Aesthetics
• Aims to characterize readability with general
optimization goals:
– Minimize
• # of crossings
• Total area
• Total edge length
• Maximum edge length
• Total number of bends (in orthogonal drawings)
– Maximize
• Angular resolution (smallest angles between two edges)
• Maximum display of symmetry
– Maintain aspect ratio of the entire drawing

11
Aesthetics
• In general, aesthetic criteria are in conflicts.

No edge crossing, Symmetric,


but asymmetric but with edge crossing

12
Constraints
• Enhance readability by adding knowledge about
the semantics of the graph
– Place a vertex close to the middle
– Place a vertex on the external boundary
– Place a subset of vertices close together
– Draw a subgraph with a specific shape

clique
i.e., complete subgraph

13
Graph Drawing
Key issues
• Graph size
– need filtering, clustering?
• Predictability
– similar drawing for the same graph every time?
• Time complexity
– Is real-time interaction possible?

14
Trees
Trees
• A tree is a directed acyclic graph:
– Exactly one unique vertex called the root with no
parents
– Every vertex except the root has a parent
– There is a path from the root to each vertex
• Trees are good for representing:
– Hierarchies (file systems, web sites, organization
charts)
– Branching Processes (family lineage, evolution)
– Decision processes (search trees, game trees,
decision trees)
16
Tree Layouts
• Indentation
– Tree depth is encoded by indentation
• Node-Link Diagrams
– Nodes connected by lines/curves
• Layered Diagrams
– Hierarchical structure represented by layering, adjacency or
alignment
• Enclosure/Containment Diagrams
– Hierarchical structure represented by enclosure

• In general, tree layout can be done efficiently in O(n) or


O(n log n) time

17
Indentation
• Items are listed in rows
• Indentation is used to
show parent/child
relationship
• Multivariate data can
be displayed in columns
• Takes up excessive
vertical space

18
Node-Link Diagrams
Breadth (branching)

Depth
(levels)

• Objects represented as nodes are distributed in


space; relationships are represented by straight or
curved lines connecting nodes
• Breadth and depth of a tree are layout in different
directions/dimensions in 2D
• Problem: breadth may grow exponentially when
branching factor is large
19
Reingold-Tilford Algorithm
The Flare visualization toolkit hierarchy
[Heer et al. 2010]

• A classical layout in which children nodes are positioned under their common
parent
• Same drawing for isometric subtrees and no edge crossing
• Leave nodes are at different levels

20
Radial Layout
• Node-link diagram but
in polar co-ordinates
• Leaf nodes are all at
the circumference
(dendrogram)
• Root node at the
center
• Visually more pleasing
and spatially more
[Heer et al. 2010] efficient
The Flare visualization toolkit hierarchy
21
Radial Layout

An animated radial tree layout


with root change

[http://philogb.github.io/jit/static/v20/Jit/Examples/RGraph/example1.html]
22
Cone Trees
• Make use of more
space with 3D, i.e.,
an additional
dimension
• Nodes at apex of a
cone
• Children evenly
Robertson et al., "Cone Trees: Animated 3D Visualizations of
Hierarchical Information", CHI'91.
spaced along the
cone base

23
Cone Trees
• An example

[https://www.youtube.com/watch?v=1eO1pgTVu-g] 24
Balloon Trees
• Children are positioned around their
parent
• Like flattening a cone tree, but
without overlapping among circles.

Carriere and Kazman, “Research Report:


Interacting with Huge Hierarchies: Beyond
Cone Trees”, Proc. of Information
Visualization '95.

[http://www.webdesignerdepot.com/2009/06/50-great-examples-of-data-visualization/]
25
Problems of Node-Link Diagrams
• Tree breadth may grow exponentially
• Easily run out of space, even with space efficient
layout
• Solution:
– Filtering
– Clustering / Aggregation
– Interactions, e.g., focus + context, scroll & pan, zoom
– Distortion (use different aspect ratios at different
regions)

26
Hyperbolic Layout

Illuminating hyperbolic geometry

[Escher]

Can you picture that


the creatures in
Escher’s drawing here
are all of the same size?

27
Hyperbolic Layout
• A distorted view of a tree so that the region in
focus has more space for layout
H

A shape of same size at


different locations of the
hyperbolic plane are
projected to shapes of
E different sizes on the
Euclidean plane

• Design a tree layout in the hyperbolic plane, then


display the layout in the Euclidean plane
How may we change the focus of the tree layout? 28
Hyperbolic Layout

[ http://philogb.github.io/jit/static/v20/Jit/Examples/Hypertree/example1.html ]

29
Layered Diagrams
Space-filling variant of the node-link diagrams
Nodes are drawn as solid areas with lengths
encoding an additional dimension
Relative position of nodes implies node
relationships
Hierarchical structure
represented by
• Layering
• Adjacency
Icicle Layout
• Alignment
30
Layered Diagrams
Another example
Sunburst Layout

[Heer et al. 2010]

The Flare visualization toolkit hierarchy


31
Enclosure/Containment Diagrams
Enclosure diagrams are space filling and makes maximal
use of the display space
Relations are represented by enclosure or containment of
shapes, e.g., rectangles / circles
Size of shapes can be used to show attributes,
e.g., country population
Colors are used to show
attributes or hierarchical
relationships
Examples:
– TreeMaps and its variants
32
Treemaps
• A compact representation by subdividing an area
into rectangles recursively
• The direction of subdivision alternates per level
Numbers represent respective data size

In this example, we subdivide horizontally at the first level

Johnson and Shneiderman, “Tree-Maps: a space-filling approach to the visualization of hierarchical information structures”, VIS '91.
33
Treemaps
• Advantages:
– Gives a single overview of a tree
– Large or small nodes are easily identified
• Problems:
– Difficult to perceive
hierarchical structure

34
Treemaps
• To enhance hierarchical structure:

Use frame / padding Use shading (Cushion treemap)


Van Wijk and van de Wetering, “Cushion Treemaps:
[Heer et al. 2010]
Visualization of Hierarchical Information”, INFOVIS '99.

35
Rectangles vs. Squares?
• Which is easier to compare, in terms of size?

Which one is bigger? Which one is bigger?

36
Squarified Treemaps
Aspect ratio of a rectangle is taken as max(height/width, width/height)
• Observation:
– we can compare better the size of rectangles when their aspect
ratios are similar.
– subdividing area in a single dimension at each level (as is done
in ordinary treemap) results in elongated rectangles.
• Improvement:
– choose either horizontal and vertical split at each level
– add a rectangle to a row only when this will improve the layout
(i.e., aspect ratio)
• Adopt a greedy approach to process large rectangles
first, in order to achieve better aspect ratios.
• Final treemap layout is not guaranteed to be optimal.

37
Squarified Treemaps
• An example
– To layout a tree node with seven children whose sizes
are 6, 6, 4, 3, 2, 2, 1 in a rectangle of size 6 x 4.

Ordinary treemap
[Bruls et al., “ Squarified Treemaps”, TCVG 2000]

38
Squarified Treemaps

Subdivide horizontally, Add 2nd rect on top of 1st Add 3rd rect on top and
and add a new rect to improve the aspect the aspect ratio worsen,
(starting from the largest ratio hence discard layout
one)

Aspect ratio of a rectangle is


taken as max(height/width,
width/height)

Subdivide remaining area Add next rect to the right


vertically, and add a new rect to improve the aspect
ratio 39
Squarified Treemaps

Subdivide remaining area Add next rect to the right Add next rect to the right and
vertically, and add a new to improve the aspect the aspect ratio worsen,
rect ratio hence discard layout

Subdivide remaining area Add next rect to the top of previous


vertically, and add a new rect and the aspect ratio worsen, hence
discard layout 40
Squarified Treemaps

Subdivide remaining area Add next rect to the top of previous


vertically, and add a new and the aspect ratio worsen, hence
rect discard layout

Subdivide remaining area Add the last rect


vertically, and add a new rect and done
41
Squarified Treemaps

• Problems:
– Change in dataset causes dramatic discontinuous change
– Orders not preserved (Solution: Ordered Treemaps)
42
Circular Treemaps
• Use circles instead of rectangles

[Tree Visualizer] [Pebbles by Wetzel]


43
Circular Treemaps
• Advantages:
– Easy to compare sizes
– Hierarchical structure is clear
• Problems:
– Not as space efficient

44
Voronoi Treemaps
• Use arbitrary polygons to fill up an arbitrary space
• Boundaries not just formed by vertical and
horizontal lines, therefore easier to see hierarchical
structure
[Balzer and Deussen, “Voronoi treemaps”, InfoVis 2005.]

[Paul Murrel, University of Auckland]


45
Voronoi Treemaps
• Use the idea of weighted centroidal Voronoi
tessellation (CVT) for generating the treemaps.
• Given a set of seed points, a Voronoi tessellation
is a partition of a domain into cells (one for each
seed point), so that every point within a cell is
closer to its seed point than to other seed points.

[ http://alexbeutel.com/webgl/voronoi.html ]

46
Voronoi Treemaps
• A centroidal Voronoi tessellation (CVT) is a
Voronoi tessellation in which all seed points are
the centroid of their respective cell.
• Seed points are evenly
distributed
• Cells are about the same
size
• Weighted CVT: seed
points are weighted so a
seed point with higher
weight attracts a larger
neighbourhood 47
a CVT
Voronoi Treemaps
How to compute a CVT for
k seeds?
Lloyd’s relaxation
• Determine initial positions
for the k seeds
• Repeat the following relaxation step
until convergence, i.e., when the site
positions are fixed (ideal case)
– Compute the Voronoi tessellation
of the k sites
– Move each site to the centroid
of its Voronoi cell
https://youtu.be/HYDSxgNT1zc 48
Voronoi Treemaps
An interactive example: https://www.jasondavies.com/voronoi-treemap/

Cells of equal area Cells of area in proportion to data values

• Problems:
– Computation involves an iterative process, which can be
inefficient
49
Voronoi Treemaps

[http://www.nytimes.com/interactive/2008/05/03/business/20080403_SPENDING_GRAPHIC.html?_r=0]

50
Reference
• Jeffrey Heer, Michael Bostock, and Vadim Ogievetsky. 2010.
A tour through the visualization zoo. Commun. ACM 53, 6
(June 2010), 59-67.
(http://hci.stanford.edu/jheer/files/zoo/)
• Matthew Ward, Georges Grinstein and Daniel Keim,
"Interactive Data Visualization: Foundations, Techniques, and
Applications", 2010 [Chapter 8]
• Isabel F. Cruz and Roberto Tamassia, “Graph Drawing
Tutorial” (http://cs.brown.edu/~rt/papers/gd-tutorial/gd-
constraints.pdf)

51

You might also like