04 Trees
04 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
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
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
3
2
3
2
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.
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
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)
• 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
[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.
[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
[Escher]
27
Hyperbolic Layout
• A distorted view of a tree so that the region in
focus has more space for layout
H
[ 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
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:
35
Rectangles vs. Squares?
• Which is easier to compare, in terms of size?
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)
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
• Problems:
– Change in dataset causes dramatic discontinuous change
– Orders not preserved (Solution: Ordered Treemaps)
42
Circular Treemaps
• Use circles instead of rectangles
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.]
[ 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/
• 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