• No results found

A layout algorithm for hierarchical graphs with constraints

N/A
N/A
Protected

Academic year: 2019

Share "A layout algorithm for hierarchical graphs with constraints"

Copied!
90
0
0

Loading.... (view fulltext now)

Full text

(1)

Rochester Institute of Technology

RIT Scholar Works

Theses

Thesis/Dissertation Collections

1994

A layout algorithm for hierarchical graphs with

constraints

Michael Slade

Follow this and additional works at:

http://scholarworks.rit.edu/theses

This Thesis is brought to you for free and open access by the Thesis/Dissertation Collections at RIT Scholar Works. It has been accepted for inclusion in Theses by an authorized administrator of RIT Scholar Works. For more information, please [email protected].

Recommended Citation

(2)
(3)
(4)

I gratefully acknowledgethe sponsorshipoftheXerox Webster Research Center

and the generous assistance ofmy colleagues, both old and new as I leftone

worldandbegan

learning

abouta new one. Eachmember ofmythesis committee,

Gil

Porter,

Stanislaw RadziszowskiandPeterAndersonhas had specialexpertise

whichtheyhave generouslysharedwithme asthe thesisgrewfrom ill-formed ideas

intoreality. Throughoutthisprocessmywife,

Judy

has beenmostunderstanding
(5)

Abstract

Anew methodisdevelopedfor reducing edge crossingsinthelayoutofdirected

graphsfor display. Themethodwillreduce edgecrossingsingraphswhichhave

constraints on the location or movement of some ofthe nodes. This has not

been available in previously published methods. An analysis ofthe strategies

usedtochooserankpairsforedgecrossingreductionshowsthat thischoice will

dramatically

affecttheamount of crossingseliminated. Thismethodis

directly

(6)

directedgraphs

hierarchicalgraphs

graphlayoutalogrithms

edgecrossings

(7)

Computing

Review Subject

Codes

Primary: G.2.2Graph

Theory

Secondary: F.2.2NonnumericalAlgorithmsandProblems

(8)

1 IntroductionandBackground 1

1.1 Problem Statement ... 1

1.2 Introduction ... . . 1

1.3 Previous Work .... 6

1.4 TheoreticalandConceptual Development . 10

1.4.1 Directed GraphDescription 10

1.4.2 Edge

Crossing Counting

13

1.4.3 Directed Graph

Drawing

.... 17

2 Implementation 25

2.1 Additional Requirements 25

2.2 Tools 26

2.2.1 Hardware 26

2.2.2 Software . . 27

2.3 DataStructures 28

2.4 Cross Count Reduction Method 31

2.5

Hierarchy

Pass

Strategy

34
(9)

2.7 Data Generation 41

2.8 System Organization . . 41

2.9 Algorithm Description 42

3 FunctionalSpecification 45

3.1 Functions Performed . . 45

3.2 LimitationsandRestrictions 46

3.3 User Inputs 47

3.4 User Outputs 47

4 ProofofPerformance 48

4.1 Basic Directed

Hierarchy

48

4.2

Dummy

Node Generation 48

4.3 DirectedGraphswithConstraints 53

4.3.1 CirclesandSquaresonDifferent Levels 53

4.3.2 Squaresbefore CirclesontheSame Level 55

4.3.3 Nodesthathave Fixed Locations .... 55

5 Analysis 58

5.1 A

Crossing

Reduction

Efficiency

Metric 61
(10)

5.2.1 A Single Example 63

5.2.2 SetsofTest Directed Graphs 67

5.3

Crossing

Reductions Missed 72

5.4 Level Pass Anomalies 73

6 Conclusions 73

6. 1 Further Improvements 74

6.2 Thegeneralgraph . . . . 76

(11)

1 INTRODUCTION ANDBACKGROUND 1

1

Introduction

and

Background

1.1

Problem

Statement

Thisthesisdevelopsa methodofreducingtheedgecrossingcount of ahierarchical

graph. Themethod includestechniques forsituationswhichhaveconstraints on

nodelocations. Sincethealgorithmignorestheedge

directivity,

it isalso applicable

toreducingedgecrossingsinthegeneral graph.

1.2

Introduction

Ahierarchical ordirected graph consists of a set ofnodes and aset ofstraight

linesthatrunbetween pairsofnodes. The

lines,

whichinadirected graphhave

an arrowhead atoneend, are called edges. A formal definition willbegiven in

section 1.4.1. Without changingthetopology, a graphcanbe displayed withthe

nodes confinedtorectangulargrid coordinates. Thenthehorizontalrows of nodes

arecalledranks orlevels.

Thedirectedgraphformsa natural representationinsuchdiverseapplications

as PERT charts, hypertext documentrelations and visualization ofthe structure

(12)

different meanings such as tasks in aPERT chart or paragraphs in ahypertext

document. Therecanbe differenttypes of nodes withinthesamegraph, suchas

nodesforauthors andothernodesforparagraphsinthehypertextdocument. The

differentnodetypescanberepresented

by

differentshapes. Eachedgealsohasa

meaning, such asinaPERTchartwheretheyshowtheorderingoftasks. Inthe

PERTchart exampletheedgesusually haveadirection indicated

by

anarrowhead

indicating

the timesequence.

Inadditiontoshowingrelationships with nodes andedges,it isoftendesirable

tohave fixedrelationshipsamongnodetypes. Forexample, square shaped nodes

mightbeshownto therightofanyround nodesonthesamelevel. Inthehypertext

example withnodes for authors and paragraphs, the author nodes mightbe in

differentranksthantheparagraph nodesinordertomoreeasily distinguish between

nodetypes.

Thevisualizationofsystemsmodeled as ahierarchical graphisoften accom

plished via graphical

display

oneitheraCRT or

hardcopy

device. The location

ofthenodes inthe

display

fixes theend points ofthe edges. However, an arbi

trarynodelayoutwill most

likely

resultinavisualizationthatconfusestheviewer

ratherthanenhances his/herunderstandingofthesystem

being

represented. The
(13)

1 INTRODUCTION ANDBACKGROUND 3

viewertogainunderstandingofthesystem

being

modeled

by

thegraph.

Notionsofgraphreadability [TDBB88,

STT81]

aredifficulttoquantify. Plac

ing

thenodes on arectilineargridismost often more aesthetically pleasingthen

a random placement. A fixed spacing betweenparallel edges alsolookspleasing,

butmorecomplex standardsfor readability are oftenhardtoexpress, muchless

quantify.

Minimization ofedge crossings andtheresultant groupingsof nodesis intu

itively

animportantaspect ofreadability. It isnotsurprising,therefore, thatedge

crossingminimization ispart ofhierarchical graphlayout algorithms. Oncethe

number ofcrossings has been reduced to an acceptable level (reduction to the

theoretical minimumisnot requiredfor readability

improvement)

otheraesthetic

considerationsmaybeapplied. Recent hierarchicalgraphprogramshave included

maximizingedge straightness

[STT81]

andminimizingedgelength

[GNV88]

as

wellas more subtlefeaturessuchastheshapeofthebends inedges [GNV88].

Application specific constraints may require nodes of different types to be

displayed on differentranks orin someorder within a rank. Alternatively, dif

ferent sets of edges may be shown indistinctviews ofthe graph while

keeping

thelocationofthenodesconstantinallviews. Thisthesisproposes a constraint

(14)

Figure 1: A directed graph with edge crossings.

algorithm whichimplements it.

Specifically,

layout algorithms which attemptto

maximizereadability have been developed forthegeneraldirectedgraph. Thisthe

sis proposes modificationsto thehierarchicalgraphlayoutalgorithm of

Sugiyama,

Tagawa,andToda

[STT81]

to allowthecase of constraints onthenode and edge

layout.

An illustration oftheproblemis showninfigures 1 and2. Figure 1 shows a

relativelysimpledirectedgraph whichhas been layedout arbitrarily. Thegraph,

G,

has a set of eightnodes, V, and a set of nineedges, E. Thereare two types

of nodes: squares and circles. The vertices are showninthree ranks orlevels

[image:14.482.128.354.105.266.2]
(15)
[image:15.482.102.380.105.265.2]

1 INTRODUCTION ANDBACKGROUND

Figure 2: Thedirectedgraph offigure 1 withnodes rearrangedtominimize

edge crossings.

is not obvious thatrearranging thenode placementwhile mamtaining thesame

connectivitycan reducethenumberofedge crossingstozero as showninfigure 2.

(The bend intheedge

(F, G)

in figures 2 and3 is a consequenceof animplicit

dummy

node which willbe explained

later.)

Ifwe require thatallcircles must

appear to theleftofanysquare within a

level,

then figure 3 shows one possible

solution. Thisthesisproposes an algorithmthatgivenagraph suchas shownin

figure

1,

willproducealayoutsuchas shownin figures 2and

3,

i.e. onewith a
(16)

1.3

Previous Work

Thepreviousworkondirectedgraphs canbe benchmarked

by

tworecentliterature

surveys of graphdrawing. Tamassia,DiBattista, andBatini[TDBB88] surveyed

theliteratureasbackgroundtogivingtheirapproachto thegeneral graph problem.

Subsequently,

Eades andTamassia

[ET88]

issued an annotated

bibliography

on

algorithmsforgraphdrawing.

Before

looking

attheautomated computertoolsfor directedgraph

drawing,

it

is instructivetoexaminethestate oftheartinmanual computergraphicspackages

thatcouldbeusedtodrawadirected graph. Here,

'manual'

meansthatthe tool

does notembody thenotion of nodes and edges andtheirplacement. 'More

11'

[Sym88]

on the Macintosh or the Viewpoint graphical editor [LENW82], for

example, are ofthis class. While bothofthese are powerful

drawing

programs,

theplacement of nodes andlinksis lefttotheuserwith,at

best,

backgroundgrid

insertion points to make the figure lookmore orderly. There is no method for

minimizingthenumberoflinkcrossings.

Trueautomated directed graphlayout tools are nowcommonplace buttheir

layout algorithms areoften notvery sophisticated. One exampleis thepopular

'grapher'

(17)

1 INTRODUCTIONANDBACKGROUND

Figure 3: The directed graph of figure 1 rearranged to minimize edge

crossingswith theconstraintthatonanylevel the squares must be to the

right ofthecircles onthesame rank.

[HMT87]. Adepth-firstsearchis done fornodes tobeplottedbutwhen across

link isrequired, thelink isnotdrawn. Insteadaduplicate'marked'

nodeis inserted.

Inordertosimplifythevisualization whenthegraphgets clutteredwith nodes and

edges, a 'virtual' nodeis usedto compacta collection of nodes andlinks into a

single node. Thevirtualnodecanbeexpandedto show additionaldetail.

Graph layout algorithms canbe categorized

by

thetypes ofgraphs handled

startingwithtreesand

becoming

moregeneral. WetherellandShannon

[WS79],

Vaucher [Vau80], and Reinhold and Tilford

[RT81]

give solutions forthe tree [image:17.482.117.370.103.275.2]
(18)

algorithm,certain additional constraints aretractable. For

instance,

iftheplanar

graph mustbenolargerthana maximumsize,hisalgorithm canbeused. Although

adirected hierarchicalgraph couldbeplanar,ingeneralit isnot. Evenifadirected

graph were planar, theWoods approachis very unlikely to yield ahierarchical

layout.

Theproblemof

finding

theminimum number of edge crossings ofadirected

graph,eveninthesimple case ofonlytwolevelswherethepositionsofthevertices

inone ofthelevels is

fixed,

has beenshowntobe NP-complete

by

Eades, et al.

[EMW85]. This does not mean that it is impossible to reduce the number of

crossings. Theniinimum numberof crossingsmay becalculated

by

permuting

vertices andthencountingthenumber ofcrossingsforeachcombination.

Any

of

the orientationsthat givethefewestcrossings isa valid solution. Thisbecomes

impractical for anyproblem with morethanafewnodes as the calculation time

increase exponentiallywiththenodecount.

There have beentwoheuristicapproachestothedirected graphproblem. The

first finds someformof a maximal planar subgraph ofthegiven graphandthen

adds the rest ofthe nodes in a fashion that tends to minimize the numberof

crossings. This method has been suggested

by

Woods [W008I].

However,

this
(19)

1 INTRODUCTIONANDBACKGROUND 9

Theother approach stems fromthework ofWarfield

[War77]

in

developing

acrossingtheoryfor hierarchicalmappings. Theproblemissubdividedintotwo

phases. The firstarrangestheverticesintoa properhierarchy,but inprinciplehas

noeffectonthenumber ofcrossingsforthe graph. Thesecond phaseis divided

into two parts. The firstpart ofthis phase minimizes the numberof crossings

betweenan adjacent pair oflevels ofthe

hierarchy by

an algorithm orheuristic

thatrearranges the ordering of vertices within a level. Thisprocedure is then

repeated with otherpairs oflevels. Thesecond partofthisphase requiresasecond

heuristictodecidetheorderingof pairs.

Whilea moredetailedanalysisofthisapproachisgiveninthenextsubsection,

some comments areappropriate here. The scheme is not guaranteed to give a

solution with an absolute minimum number ofcrossings; it only yields alocal

minimum. Several differentalgorithmshave beenusedtodecidetheorderingof

pairsoflevelstosubjectto thecrossingreductionprocess,i.e. godownpairwise

forsomearbitrarynumber of passes or alternatebetweena passgoing downand

thenonegoingup. Noneofthemavoidstheproblemthat themovement of a node

alongaranktoreducethenumber of crossingsbetween itsrankandtherankbelow

may increasethenumberof crossingsbetween itsrank andtherank above. It is

(20)

count.

Almostno attentionhas beenpaidto theproblemof

laying

outahierarchical

graph withconstraints. Gansner

[GNV88]

considersthecaseof edges ofdifferent

weight inwhich thealgorithm places greater emphasis ontryingto shorten the

links ofhigherweight. Butthemore general problem ofapplyingconstraintsto

thelayoutofadirected graphhasnotbeenaddressed. Exampleapplications that

require constraints wouldbe

keeping

thecritical pathinaPERTchartvertically

aligned or

having

direct staffreports on adifferentrank than linereportsin an

organizationchart.

1.4

Theoretical

and

Conceptual Development

1.4.1 Directed Graph Description

ThenotationanddefinitionsusedhereinarethatofSugiyamaet al

[STT81]

which

followthatofWarfield

[War77]

with oneexception: hierarchies havetheir"roots'

atthetopwhichis level 1. Asalreadynoted,adirectedgraph

G(V, E)

iscomposed

of a set ofvertices, Vand a set of edgesE. So

far,

therehas beenno restriction

on wherethesetof verticesareplacedintheplane.

(21)

1 INTRODUCTION ANDBACKGROUND 11

pointsof arectangularlatticecanbeaccomplishedsothatit doesnot change the

topologyofG. Thisallowsthedescriptionof subsets ofVwhichare somewhere

on a horizontal level (row orrank) nt.

Expressing

thepartitioning ofV into n

subsets as

v=

VAV2u---uvn

(vinvj

=

9,i^j)

(D

givesan n level

hierarchy

withthesubset

Vj

attheithlevel. Thenotation fora

directedgraph of nlevels is G=

(

V, E,

n) wheretheorderofthevertices within

alevel hasnot yetbeen described.

Foreachedge

e=

{vi,Vj)

G

E,

withV{ G

V;,

Vj G

Vj

andi <j.

(2)

There are several implications ofthe requirement that i < j. First there can

be noedges between nodes onthe same level even ifthey are adjacent, i.e. in

figure 1 theremaynotbeedges

(A,

B)

or

(D, E)

or

(D,

F). Therestriction on

edgesbetween adjoiningvertices canberelaxedwithout mucheffort, andinthis

implementation it is another form of constraint.

Second,

all edges must point

downward andthuscycles arenot allowed. Onceagainthisisoverly restrictive.

Someworkershaveused appropriatetemporaryarcdirectionreversalstoovercome

(22)

Theedge

(A, G)

offigure 1 spans morethan

level,

ie

j

i > 1. Ifalledges

span onlyone level then the directed graph

is,

by

definition,

a proper nlevel

hierarchy.

Continuing

withtheformulationofSugiyama,thisisequivalenttostatingthat

E =

E1UE2---\JEn.1

(EinEj

=

$,iAJ)

(3)

where

E{

c

Vj

x

Vj+i,

i =

1,

. . .

,n 1. Notethatrequiringthat theends ofthe

edges in eachsubset

*,

comefrom adjacentlevels forces the

hierarchy

to be a

properhierarchy.

Any

hierarchy

may be made into a proper

hierarchy by inserting

'dummy'

vertices ofdegreetwoateach oftheintermediate levelsofanyedgewhereji > 1.

Ifthese additional vertices are inserted alongthe edge they do notchange the

number of edgecrossings; the original and new grapharehomeomorphic. For

examplethe

hierarchy

offigure 1 canbemade proper

by

theinsertion of vertex

Konlevel 2 betweenvertices CandDwithedges

(A, K)

and

(K,

G)

replacing
(23)

1 INTRODUCTIONANDBACKGROUND 13

(a) (b)

Figure4: Topological possibilitiesfor twoedges,

(a)

Edges thatcross,

(b)

Edgesthatdo not cross.

1.4.2 Edge

Crossing Counting

Foraproper

hierarchy,

thenumber ofcrossings is onlyaffected

by

the ordering

ofthevertices and nottheirseparation. Eachlevelconsists of asubsetofvertices,

Vj, whose orderisa, = v\v2 v\v,\, where

|

V;

|

isusedtoexpress thenumber

of vertices inthesubsetVj. Theset a

(<7i,

. ..

,cr) givesthe orderingsforall

levelswithinthenlevel

hierarchy,andthedirectedgraphiscompletely defined

byG= (V,E,n,a).

The crossingreduction problem now canbeexpressedfor any G=

(V,E,n,a)

as

finding

aseta whichminimizesthenumberof crossings. Inordertodecide

whichset a yields theminimal crossingcount, a methodisneeded tocountthe

numberof crossingsforagiven a.

[image:23.483.114.373.104.213.2]
(24)

edges cross. Figure 4showsthetopologicalpossibilities.

Even inthesimplest caseoftwoedges

(u,

r)and(v,s),

determining

whether

theedges crossis easytodo

by

eyebutmustbeexpressedmathematically. What

isneededistoexpressthedifference betweenthecase offigure

4(a)

and(b). Let

X(i)

bethexcoordinate of eachvertex. Rememberthat the actual valueofthe

x coordinates isnot

important;

onlytherelativeorderingof vertices within each

levelmustbepreservediftheedge crossingsare tobeuneffected. Then, ifthe

sign of

T=(X(u)-X(v))(X(r)-X(s))

(4)

isnegative, theedges cross[EW89].

However,

theneedfora multiplication step

is computationallyexpensivebutcaneasily beavoided.

Oneapproachtocalculatingthenumber ofcrossingsfora given aistoapply

theprecedingproceduretoall pairs of edgesemanatingfromall pairs of vertices

withinalevel andthensummingover alllevels. Amoreelegantformulation of

thesolutionwasgiven

by

Warfield[War77,equations2-4].

Figure

5(a)

showsa2-level

hierarchy

and

(b)

its adjacencymatrix. Ingeneral
(25)

1 WTRODUCTION ANDBACKGROUND 15

rowinthematrix

ir =

ri,r',...,rj,...,rfVi+i|

(5)

isasequenceofl'sandO's

indicating

whethertheithvertexinsequenceothasan

edgethatgoesto thejthvertexinsequence at+\. Thenumber of crossings caused

by

theedges whichemanate fromtwovertices on the samelevel

K{R\W)

is

given

by

K(Ri,Rj)

=

J2 E

rir;,wherep=|Vm|.

(6)

r=l p=r+l

Inorderto seethismore clearly,figure 5

(a)

has beenredrawnin figure 5

(c)

to

showonlytheedgesforthecasei =

b, j

=c. Ifr=

/

andp =

h,

theproduct

y

=

y

= i-i = i

(7)

showsthat thesetwoedges cross and mustbe included inthesummation. Since

r{rp

istheproduct ofonly l's and

O's,

it isequivalent to alogical and,r{ Ar'p,

whichiscomputationallymore efficient ontypicalcomputers. Thelimitsonboth

summations in equation 6take into account thefact thatedges drawn fromall

vertices in

Vt

thatconnectto thesame vertexin

Vt+\

cannot cross.
(26)

(a)

e fghk

al 110 0

bl 0 0 10

cO 10 0 1

dO 0 1 1 0

(b)

(c)

Figure5:

(a)

A 2-level

hierarchy

and

(b)

itsadjacencymatrix. The

hierarchy

[image:26.482.108.381.139.484.2]
(27)

1 INTRODUCTIONAND BACKGROUND 17

sumover all pairs of verticesintandisgiven

by

ro1 m

(*)

=

k(r,rW)

(8)

=1 j=i+l

andthe totalof allcrossingsCtotalinthenlevel

hierarchy

isgiven

by

Ctota,

=

c(t).

(9)

1.4.3 Directed Graph

Drawing

As previously

indicated,

thealgorithmfor

drawing

directed graphs hastwoseg

ments. Thepurposeofthefirstpartistomakethegraph a properhierarchy.

Previousdirectedgraphlayoutalgorithmshavenotincluded layoutconstraints.

Whenthedirectedgraphlayout includesa constraintthatrequires nodes ofdifferent

typestobeon separateranks,theseparationis best donepriortomakingthegraph

proper. Iftheimplementation ofthisformof constraintis delayeduntil afterthe

hierarchy

isproper,thegraphis very

likely

nottobeproper aftertheconstraintis

imposedand willhavetobemade proper again.

Anexampleofthis typeof allowed constraintisthatcircle and square nodes

mustbeonalternatelevels. Figure6isthedirected

hierarchy

offigure 1withthis

modification. Intheredrawingnew edgecrossingsmayoccur.

(28)
[image:28.482.129.362.140.473.2]

Figure 6: The

hierarchy

offigure 1 with theadded constraint thatcircles
(29)

1 INTRODUCTIONAND BACKGROUND 19

figure 1 or figure 6suggeststhat theabsolute xposition ofa nodedoesmake a

difference inthenumber ofedge crossings. Ifnode C were shiftedto theright

closerto nodeE (i.e. putting itontherightofedge

(A,

G)),

onecrossingcould

beeliminated withoutchangingtheorderingofthenodeswithinalevel. Asimilar

situationinvolvesedge

(F, G)

.

Thispotentialambiguity isresolved oncethe

hierarchy

ismadeproperasthe

hierarchy

offigure 6 has been in figure 7.

Crossing

amongedges thatoriginate

amongnodes on adjacent ranks cannotbeaffected

by

theabsolutexposition ofthe

nodes. Someattentionisrequiredto the

dummy

nodeinsertionprocess. Theopen

numbered square nodes aretheadded

dummy

nodes.

Separating

adjacent nodes

within alevelmayberequiredtoputinthedummiesonthesamegridastheset of

real nodes. Heredummies

5,

6and7neededtobesqueezedin between CandE.

Ifthis is donecorrectly, boththenumber ofcrossings andtheimplicitrealnode

toreal nodeedges involved ineachcrossingarethe same asbeforethe

dummy

nodes wereadded. Now, eliminating anyedgecrossingrequires areorderingof

thenodes within alevel.

Animportantcharacteristic of

dummy

nodes isthattheyactjust likeregular

nodesinthereorderingalgorithm. Inthisimplementationa

dummy

nodemay have
(30)
[image:30.482.58.423.139.471.2]

Figure 7: The

hierarchy

offigure 6after

dummy

nodes have been added
(31)

1 INTRODUCTIONAND BACKGROUND 21

dummy

nodes could alsobeusedtoreduce graphcomplexity

by

collapsingseveral

nodesandtheirconnectingedgesintoonenode; then theremightbemorethantwo

edges connectedto the

dummy

node. This collapsingintoone nodetechniquehas

beenused as a methodof

deleting

cyclesfromthegraph;inthisimplementation

cycles are allowed. Bends intheimplicitreal edgetakeplace at

dummy

nodes;

thiscanbeusedinroutinesthatimprove readability

by

modifyingthebendshape

orlocationaftertheedgecrossingreductionprocess.

Vertex F offigure 7 illustrates animplementation dependent decisionwhich

mightbe considered adifferenttypeoflevel-based constraint which will notbe

consideredhere. F could be inthefirst level (as was done inthe redrawingin

figure

2)

oralternativelyin leveltwoor evenin levelthree. Leveloneisappropriate

ifthere isa constraint which requires all nodes shouldbe inthehighest (closest

tothetop)rankpossible. Otherconstraintdefinitions (shortestedges,lowestrank

possible)resultin levelthree

being

theappropriatelocation.

Thecrux ofthealgorithmisparttwowhichcreates a new setaoforderingsfor

eachlevel. Parttwonaturally separatesinto two subparts, therearranging ofthe

individual levelorderatandtheiterationover alllevels. Twoapproacheshave been

taken to theindividuallevelaspect. (Individuallevel is reallya misnomer. Since

(32)

involved,

buttheusual practiceis onlytorearrangethevertices on one ofthem.)

Oneapproach canbeconsideredadirectmethod andtheotherindirect.

The direct method actually monitors the crossingcount. Warfield [War77]

pioneered this technique using interconnection matrix manipulations but itwas

limited to asmall number of vertices because ofthe computational complexity.

Sugiyama,

et al

[STT81]

expandedthemethodtolarger hierarchiesbut itstillhad

thecomputational expenseproblem. Thesedirectmethods areonlyusedtocheck

theresultsoftheindirectmethodinsmall examples.

Eades and

Kelly

[EK86]

used adifferent but stilldirectmethod with several

variations. All are sorting schemes,

(greedy

insertion,

greedy switching and

splitting), based on minimizing the total crossingcountbetween thetwolevels

being

adjusted. Firstonelevelissorted andthen theotheris doneuntilnofurther

reductionis gained. Theirperformance testsshow results similartoSugiyama's

averaging indirectmethod. Althoughtheyonlytestedtwolevel

hierarchies,

their

methods canbeusedin larger hierarchiesas willbeexplainedlater.

The indirect method was developed

by

Sugiyama

[STT81]

and has since

givenbirthtoseveral variants[RDM+

87]

[Mey83]

[Dav85] [GNV88]

[TDBB88]

[Sug87] [EK86]

[ET88]. The basicconceptis to

keep

a vertexin level i 'near'
(33)

ver-1 INTRODUCTIONAND BACKGROUND 23

ticesare, theless likelytheiredgewillcrossanother edge. That

is,

infigure 7 if

vertexFwere nearervertexlO,theless

likely

edge

(F,

10)

wouldcrossanyother

edge.

Using

theindexvx,i.e. thexcoordinate ofthevertexasthemeasureofits

positionwithintherow,themethodtranslates to

having

the xcoordinate ofthe

vertexin level i beas closeaspracticalto theaverage ofthexcoordinates ofthe

connected vertices in level i+ 1. Sugiyamacalled this thebarycentric method.

Ratherthanusingthe mean, themedian could alsobechosenasthexcoordinate.

Eades

[EW89]

provedthatusingthemedian gives an upperlimitofthree times the

optimalnumber of crossings. Anupperboundwasalsogivenfor usingthe mean,

i.e.

barycenter,

method.

Some consideration mustbegivento thesortingmethod usedintheindirect

method in order to be computationally efficient. All the standard criteria for

choosingamethod could apply. Hereit is

likely

that thenumber ofnodeswithin

arankis goingtobe relativelysmall,i.e. ontheorderoftensof nodes ratherthan

thousands perlevel. Except forthe initial pairings of

levels,

eachrank willbe

closeto

being

orderedeachtimeitneedstobesorted.

Aspart ofthewithin-levelorderingprocess,thisthesisaddsthepossibilityof

including

level order constraints. Eitherthe xposition calculation orthesorting
(34)

where squares mustbeto theright ofcircles onthesame rank, themore

likely

control pointisthexcoordinatecalculation.

Whatever technique is used for the pairwise level edge crossing reduction

process,itwillproduce alocalminimuminone pass. Thesameisnottrueforthe

iteration overall adjacent pairs oflevels. Sugiyama originally performed several

iterations ofalternatively goingpairwisedown the

hierarchy

and then going up

the

hierarchy

forafixed number of passes or until there was nocrossing count

reduction, whichever camefirst.

Only

afewpasses, usuallylessthan

five,

were

themaximumattempted. On thedownwardphase, level i was sorted andlevel

i 1 was fixed ('down

barycenters')

andon the upward phase level i + 1 was

sortedandlevel i washeld fixed

('up

barycenters'). Variousalternatives, suchas

averagingtheupanddown barycenters have beenused,buttests

[GNV88]

have

not suggestedthatone methodis far betterthananother. This isthemost empirical

part ofthealgorithm.

Afterthecrossingreductionprocess,mostdirectedgraphalgorithms add other

readability improvementoperations.

Typically

astraighteningalgorithm isused

to takeout excesskinks ineach edge. Sometimesthisis followed

by

analgorithm
(35)

2 IMPLEMENTATION 25

2

Implementation

2.1

Additional Requirements

Thisthesis presentsimprovements and extensionsto heuristics which minimize

thenumber of crossingsinthehierarchicalgraph

drawing

problem. As suchthe

implementation does not needto concern itselfwithsome ofthe preprocessing

andpostprocessingstepsrequired ofa completedirectedgraph

drawing

package.

Theimplementation must,

however,

facilitatethe incorporationof extensions

which willhandle hierarchical graphsthathave some added constraints on node

placement. Thegeneraltechniquewillbe demonstrated

by

several examples.

Oneconstrainttype thatwillbe demonstrated isanexampleofnodesthathave

beenrequired toremainintheirinitial location as other nodes onthe same rank

are relocated toproduce alower crossingcount.

Anotherconstraintexampleisthecase where one set of nodes mustbe before

or after anothersetonthesamerank,suchas: squares mustbeafter circles. Inthis

exampletheordering amongthesquares oramongthecircles can stillbechanged

toreducethe totalcrossingcount.

Athird constraint typewill require amethod ofrebuilding the

hierarchy

ac
(36)

process. An example ofthis typeis a constraint thatrequires nodes whichare

circles not beon the same rank as nodesthat are squares. Theprevious exam

ples require a method ofchecking fortheconstraintsatisfaction

during

the level

reordering process. Here, and for other constraints ofthis

form,

a method of

rebuildingthe

hierarchy

accordingto theconstraintprescription priorto crossing

countreductionisrequired.

The implementationshouldalsoberobust. That

is,

itshouldbeabletohandle

graphs ofindeterminatesize andshouldbe flexibleenoughthatitcanbetailored

tobeusefulin differentapplications. Theinitialapplicationisexpectedtobe ina

hypertextenvironment which would requiretrackingofnode andlinkattributes.

Fromaprogrammingperspective, theeleganceoftheimplementation wouldbe

enhanced

by

a clean separationbetweeen actions that reorganize the graph and

those that

display

thegraphrepresentation.

2.2

Tools

2.2.1 Hardware

Thesoftware associated withthis thesishasbeen developed onSunworkstations

(37)

2 IMPLEMENTATION 27

hardcopy

output, either listings orfigures. Theequipment was interconnected

over anextensive ethernetwhichruns alarge varietyofprotocols,

including

XNS

andTCP/IP.

2.2.2 Software

Sincethemainthrustofthiswork was thecalculation ofthenode positions of a

directedgraph,anyone of avarietyofprogranuning languageswouldbesuitable.

Thechoice ofC++ (Sun'sversion ofATT Cfront

2.0,

but

initially

1.2)

enabledthe

use of an object-oriented style.

Arequired adjunctwassome methodfor

displaying

thegraphsboth beforeand

aftercrossingreduction. Whilemanualplottingthegraphswouldhavegiventhe

required

information,

itwouldhave rapidly becomeatediousprocess. Publication

qualityprinted graphs

hardcopy

printed also were neededforthis thesis. Tomeet

both goals, functions were written that generate PostScript descriptions ofthe

graphs. Eithertheworkstation's windowingsystem and aPostscriptpreviewer or

aprinterthatunderstandsPostScriptwas usedfor

displaying

thesegraphs. Other
(38)

2.3

Data

Structures

Attheveryminimum,datastructures are requiredfornodes, edges, ranks,andthe

adjacency matrix. Ifthestructure fornodes andedges istobe usefulina more generalsystem, moreextensive structures are required. Provisions forattributes

ofbothnodes and edges aswellas node contentsmustbe included.

The more generalized linked fist structure for nodes and edges which was

createdisshowninfigure 8. Theadded structureforattributes was usedtostore

the value ofthe nodeshape (ie. circle orsquare). Head infigure 8represents

theroot ofthelinked fiststructure. Themainlinked fistconsistsof one or more

Nodes. EachoftheNodestructures onthelistcontains a setofdata for itself

(x,y

location,

etc.) and alinked fist for its EdgestootherNodes. The Nodestructure alsohasalinkedfistattachedtoitself for itsattributes.

Notethateachnode storesonlyalinked listof pointersto thenodesthatmake

uptheoppositeendof attached edges. Thex,ylocation ofthenodes attheother end of each edge mustbeevaluated viathestructure ofthenodeattheotherend oftheedge. Thisformatalso requiresthateach edge willbe

doubly

countedinthe

overallstructure sinceitwillbeontheedgelinkedlist forthenode ateachendof

(39)

2

IMPLEMENTATION

29

head

x,y,

name pointer

nodetype

contents pointer

Node Link

Nodepointer

enddirection

Attribute state

Attribute

state

pointers

Figure8: Thenodelinked liststructure. Arrows mayeitherbenull pointers

[image:39.482.123.364.205.421.2]
(40)

head

rankindex

rank ranknode

"

[image:40.482.146.344.101.259.2]

pointer

Figure 9: Therank linked liststructure. Arrows mayeitherbenull pointers

or pointerstoadditional elementsin their linked lists.

Thedatastructureforranksisshownin figure 9. This onlyrequiresthestorage

ofthenode pointersforeachnodeinarank.

Typically

ranksare storedin ascending

index order and node pointers fora rank are storedin

increasing

order oftheir

ordinate.

Unlikethenodeandrankstructures,asimple matrixisusedastheadjacency

matrixdatastructure. Althoughmore efficient storage usage wouldsuggestusinga

bitwisestoragescheme,anintegermatrix was used. Inthis situation,therequired

matrix isrelatively small (the product ofthe number ofnodes on two adjacent

(41)

2 IMPLEMENTATION 31

2.4

Cross Count Reduction

Method

Thefirstchoicein

deciding

onthecrossingcount reduction methodis inchoosing

betweenadirectorindirectapproach. Eades [EK86,figure

3]

hasshownthatfor low edge

densities,

anaveraging

(indirect)

technique produces fewer crossings.

However, at higher densities the results are essentially the same as the greedy

switching

(direct)

method.

However,

ifspeedis

important,

theanalysis showsthat thegreedy switchingmethod comes out alittle faster.

Anotherconsiderationistheeaseofimplementationof constraints. Ifagreedy

switching technique is used, before every switch the constraint condition may

be easily tested

by

checking ifthe swap isallowed. Intheaveraging

(indirect)

methods,constraint satisfactionisalittlemore complicated.

Unlike theEades studies on simple n=2 layered networks, adirect method

forahigherordernlevel

hierarchy

requires morethana singleadjacencymatrix

calculation. Forn>2theadjacencymatrix mustberecomputedeachtimeapair of

levelsischosenfor crossingcount reduction. Additionally,foreach proposedswap

of nodesinthegreedyswitchingprocess, thecrossingcount mustbecalculatedin

ordertocheckiftheswapwould resultinareducedcrossingcount.

(42)

theadjacencycalculation andtheneedfor

including

constraints indicates greedy

switchingasthemethodofchoice.

Greedy

switchingcanbeconsidered analogous

toabubblesort. Iftheswappingoftwoadjacent nodes reducesthecrossingcount

(analogoustoseeing iftwoitemsshouldbeswappedtoimprovethesortingorder),

theyareswapped. Therankdatastructureimplementationrequires asimple node

pointerandnode ordinate valueinterchangetoaccomplishthis.

However, theEades formofsimplegreedy switching fails on apathological

case,whichcanbeseenusingtheconfigurationinfigure 7. Assumetheparticular

orderingof nodeshad been formed

during

acrossingreduction processthathad

started withlevelspairedstartingatthebottom (here level

5)

withlevelabove

(4)

held fixed. Thiswouldbeconsideredpairing

by

going back

facing

up. With the

appropriatechoice ofstartinglevel,therearefourcombinations,

forward/down,

forward/up,

back/up

andback/down.

Attheinstance

during

thissequenceillustrated

by

figure7,nodes withinlevel

2 are going tobe swappedin orderto nrinimize thecrossings between level 1

(nodes A and

B)

and level 2 (nodes

1, 2,

D,

3 and4). All the nodes in level 1

(andall nodesin levels 3or

higher)

areheld fixed. Changes inthecrossingcount

betweennodesin level 2andlevel 3as aresult ofthenode exchanges withinlevel

(43)

2 IMPLEMENTATION 33

Theproblem centers around nodeD in level 2.

Ideally

node 1

(ignoring

where

node Cshouldgo)shouldbe betweennodes 3and4orafter4.

Swapping

nodes

1 and2reduces thelevel 1-2crossingcount

by

one so theswap will be carried

out. Butwhenthetimecomesto testswappingadjacent nodes 1 and

D,

thereis

no crossingcount reduction and 1 becomespinnedto theleftofD. Thiscannot

happen intheEades 2-level examples because each nodehas at leastoneedge,

otherwisethereisno usefor it intheexample!

An increase inthecomplexityofthegreedyswitchresolvestheproblem. All

possible pairs ofnodesonalevelare tested. The cost

is,

ofcourse, anincrease

in computingtime. Notethatin boththesimple greedyswitch andthemodified

greedyswitchimplemented

here,

morethanone passisrequiredtopercolatethe

nodes to thepositions whichreflecttheminimumcrossing count.

However,

the

modifiedgreedyswitchrepresentsa significantimprovementovertheworst cases

ofthesimplegreedyswitch. Intheworsecaseforthesimplegreedy switch,like

thebubblesort, a nodeattheopposite endfrom its desiredpositionismoved

by

swappingon placeat atime

by

adjacent node swapping. Inthemodifiedgreedy

switch,anode can movemultiplepositionsinoneswap,possibly

taking

onlyone

swaptogettowhereit 'belongs'.

(44)

oftwonodes at atimeare affected. Node 1cannotgettoits 'desired' place

by

a

simple swap.

Checking

a complete set of all combinations ofnodes on onelevel

isconsidered onepass. Since it isnotknown howmanypasses are required until

a pair oflevels produce acrossing count minimum, passes are repeated until a

passfailstoproducea reductioninthecrossingcount.

Specifically

not considered

aretheeffectsonadjacentcrossingcountsandthepossibilitythatswappingnodes

whichproduce no changein crossingcount mightleadtoan eventuallowercount

forthepair oflevels.

2.5

Hierarchy

Pass

Strategy

Asnotedinthepreviousdiscussion,therearefour basicmethodsof

doing

a setof

level crossingreductionsforan entire

hierarchy,

i.e. a

hierarchy

pass(HP). Various

combinations have beensuggested [STT81,

RDM+87, Car80]

and an estimate of

thenumber ofHPcyclestousegiven,butnoanalysishas beenproposed.

Among

thesuggested strategiesarerepeatedHPdownandalternating downandup. An

indication ofhow manyHPsare required usingthese strategies canbe seen

by

looking

atfigures 10-12.
(45)

2 IMPLEMENTATION 35

(a) (b) (c) (d)

Figure 10:

(a)

Before any

hierarchy

passes and level reductions,

(b)

Afterfirstforward/downonlevel 1.

(c)

Another forward/downonlevel 2. [image:45.482.95.393.212.410.2]
(46)

6

6

6

6

(a)

(b) (c) (d)

Figure 11:

(a)

After the forward/down pass on level 4.

(b)

After the

start ofthesecondHPwitha

forward/

down pass onlevel 1.

(c)

After the forward/downpass onlevel 2ofthesecondHP.(d)Afterthe

forward/

down

pass on level 3ofthesecond HP. Another

forward/

downon level 3.

reduction. At every point we will assume that the level crossing algorithm is

perfect andreducesthelevelcountfrom 1to0. Successive

forward/

down level

passes on each levelareshown in figures

10(b)

through 11(a). Notethat after a

completeHP onlyasinglecrossinghas beeneliminated; theeffect ofeverylevel

pass afterthefirst has just beentomovetheuncrossedpointdownthehierarchy.

Theresults oftheindividual levelpassesforthesecond set offorward/down

[image:46.482.89.398.80.309.2]
(47)

2 IMPLEMENTATION 37

<B

o

o

(a) (b) (c)

Figure 12:

(a)

Thefirst

forward/

down level pass ofthe third HP.

Finally,

afterthecompletion ofthefourth

HP,

a zerocrossingcount.

level pass on level 4 is not needed onthis HP. It is tempting to assumethat a

decreasing

number oflevelpasses are required on successiveHPs butthere are

counter examples which showthisassumptiontobe invalid.

Only

one level pass ofthe third HPchanges the

hierarchy

at all. Thestatus

afterthe third HP is complete is shown in figure 12(a).

Only

the second level

pass ofthe fourth HPchanges the

hierarchy

astheremaining crossing ismoved

upasseeninfigure 12(b). A fifth

HP,

thesamenumberasthenumber ofranks,is [image:47.482.133.354.100.309.2]
(48)

the

hierarchy

withoutanycrossings.

Surprisingly,

forthis example,alternating

forward/

downandback

/up

HPs

can require more HPs thanjust successive forward/down HPs. As indicated

earlier,thecompletion ofa

forward/

downHPis showninfigure11(a). Nowa

back/

upHPatthispointistopologicallythesame as

being

atfigure10(b),except

for the node labels.

Completing

the back

/up

HPwould result in figure

11(a)

whichisthesame asthestart ofthisHPexcept upsidedown. Thenthe thirdHP,

a

forward/

downsetwouldbeginatthestageoffigure

10(b)

again! Successive

HPunderthealternatingscheme onthisexamplefailtogivetheknownminimum

solutionyielding only a slight improvementoverthe original crossing countin

reducingit only

by

1 !

An analysis oftheproblemindicatesthat

forward/up

and

back/

down HPs

aresurprisinglymore efficientin reachinga relativeminimumtotalcrossingcount.

Asingle

forward/up

orback/downHPmust yieldalocalminimum. Although

usingeitherofthese twomethodsis

likely

to increasethecrossing countinthe

level pair thatfollows eachstep intheHP, a secondHP usingthesame method

producesnochanges! Away tolookatthisisto thinkofthisas atubeoftoothpaste

being

rolledup fromthe

bottom,

pushing theknotof crossingstoward theedge at
(49)

2 IMPLEMENTATION 39

HP beginsatlevel

2,

adjustingtheposition ofCandDinordertominimizethe

crossingswithlevel 1 nodesAandB.

(

Aforward/downpass atlevel 1 could

have been doneto takeadvantage ofadjusting level 1 nodesalso).

Rearranging

the level 2 nodesin a

hierarchy

with more nodes ateach level

is likely tohavemade thecrossingcountbetween level 2and3 worse, although

in this case it makes things better. But once the

forward/up

pass is done at

level two, thenextstep in theHPwill not affect therelationship between level

1 andlevel 2. Notethatthis is different fromthe

forward/

downHPtechnique

describedearlier. Another

forward/up

completeHPwillfind level 1 andlevel

2unchangedfromthefirst HPandany improvementthatcouldbe done has been

done already! This is nottostate thatno further improvements are possible; a

down

facing

HPmightpossiblyfindan evenlowerrelativeminimum,butsinceit

will affect changes made

during

thepreviousHPthingscould getworse. Given

that there aretwo typesofdown

facing

HPs,

once again, the onethatsqueezes

complexity alongthe

hierarchy

aheadof

it,

i.e. back/downmightbe desirable.

Inordertomore

fully

explorethepossibleHPsequences, thesoftwarehas been

implementedthatdoesanyofthepossible combinationsdiscussedabove plusany

individualpair of adjacentlevels

facing

ineitherdirection. One

interesting

possible
(50)

software alsohasthiscase.

2.6

C++

Classes

Thedesiretoseparatethegraph manipulationsfromthenode storageandmanipu

lationsresultedinadesignwithtwoclasses,NodeListandBrows. NodeList

containsthenodeandlinkcreationfunctionsandanythingthatoperateson nodesor

links. Brows(namedearlierasaclassthatstartedlifeasabrowserconstruction)

does thehigher level graph oriented functions as

loading

(graph input), adding

dummy

nodes, countingcrossings,etc. Browsisnotderived fromNodeList

althoughthisclearly isan alternativeformulation. Atthetime theseclasseswere

being

implemented,

multiple inheritance was notavailable inthe 1.2version of

Cfront,theAT&T C++translator. Since bothnodefunctionsand

displaying

func

tionsweredesired in Brows, itwas unclear whichtypeofbase class shouldbe developed. Instead,the technique ofusinga private pointertoaninstanceofthe

'base'

classisused. Ifnecessary, thisallows a classtohavemultipleinstancesof

(51)

2 IMPLEMENTATION 41

2.7

Data

Generation

Test hierarchical graph data has been generated

by

two methods. Thefirst is

manuallywritinganinput file.

Only

smallhierarchies

(

typicallylessthanadozen

totalnodes on all

levels)

are practicaltoimplement

by

hand. However,thiswas

the technique of choiceto

debug

the software as each function was developed.

Testcaseswereconstructedthatcheck rankordering,

dummy

node generation and

insertion,

etc.

Performanceand analysisofthesystemrequiredlarger hierarchiesand random

placements. Intheseinstances aseparatedatagenerationprogram, dater,pro

ducedtherequiredinput files. Parameters includedthenumberof ranksdesired,

nodes per rank and

density

oflinks andthenumberoftestcases desired. Shape

functionswerebuilt insothathierarchieswiththesame number of nodes on each

rank, the samenumber of nodesas the rankindex (i.e. linear

increasing),

etc.

couldbegenerated.

2.8

System Organization

Anoverall perspective ofthesystem organizationisshownin figure 13. Testcases

(52)

display

filegeneration program. Ifthereareconstraintstheyaredefinedasseparate

moduleswhichare referenced

by

themainprogram. Thegraphs associated with a

particulartestcanbeviewedviathePostScript

display

previewer or via

hardcopy

output. The main program will also output information about the number of

crossingsbeforeand aftercrossingreduction which canbeusedintheanalysisof

performance plotting.

2.9

Algorithm Description

Ahigh levelview ofthealgorithmdeveloped foredgecrossingreductioniselegant

but

deceptively

simple:

load the graph

if necessary

separate by vertical constraint

make rank order list if necessary

reorder rank by constraint condition

add any required dummy nodes

as per desired hierarchical pass strategy

reduce the crossing count each required level pair

At any time

during

the process a PostScript

display

ofthe graph may be

generated. After the graph is proper,

ie,

any needed

dummy

nodes have been
(53)

2 IMPLEMENTATION 43 Test Case Generation Constraints Graphs

Crossing

Reduction and

Plotting

Graph(Brows)classdefinition

Analysis Plotting * Brows Functions X NodeListClass Graphical Output PairwiseLevel Iteration CrossCount Reduction Data Output

Data Flow User Input

Figure 13: Anoverviewofthe programs, theirmajor components andthe

[image:53.482.25.460.170.450.2]
(54)

The most

interesting

parts ofthe algorithm are included in the level pair

reduction process andtoamuchlesserextent,the

dummy

insertionprocess.

The

dummy

insertionprocess proceedsasfollows:

for each rank starting at the top

for each node in the rank

for each attached edge in a greater rank if the rank difference is greater than one

insert a dummy

The

dummy

rankis known butthexlocationneedstobe decided. Theproce

dure for

doing

thisis:

if next rank is empty

put it directly below this node

else

find closest place to the left below here

find closest place to the right below here

put it nearest to below here

Actualedgecrossingreductiontakesplaceinthereducelayer function. Given

thelevelandtheleveleither aboveorbelowas appropriateto thehierarchicalpass

(HP)

strategy:

create an adjacency matrix count crossings

(55)

3 FUNCTIONAL SPECIFICATION 45

if ok to swap based on constraints

make a temporary adjacency matrix swap

count crossings

if edge count is less

make swap permanent

reset running crossing count

Since an edge count for an entire level pair is required foreach swap, the

computational costscouldbe high. Thereplacement ofthemultiplication ofthe

sign computationinequation4

by

alogicalandasindicated

following

equation7

probably isasignificantincrease incomputational efficiency.

Althoughtheanalysishas broken downthealgorithminwhatlooks likesmall

simplechunks, implementationrequires severalthousand linesof code and com

ments.

3

Functional Specification

3.1

Functions Performed

Given an ASCIItext listof nodes andedges, theprogram written forthis thesis

inputs the data and then after processing can produce output PostScript files

representingplots ofthegraphaswellasstatistics suchasinitialandfinal crossing

(56)

orusedasinputtoaPostScript

display

previewer. Theprogram can alsobe setto

produce anoutput

listing

ofnodes,edgesand coordinates. Several differenttypes

ofconstraintshave been built intothesoftware and additional onesmay beeasily

addedviaa recompilation of a single module. Thereafterthechoice of constraints

canbesetfromamainprogram parameter which couldbe input from cin(C++

stdin)orafileasappropriate.

Testfilescanbegeneratedusingthedaterdirectedgraphgeneratingprogram.

Inputrequired for daterincludes number ofranks,maximumnodes perrank,

nodesper rank(fixed,linear

increasing

,etc),edge

density

factorandnumberof

directedgraphsdesired.

3.2

LimitationsandRestrictions

Theinput isassumedtobea validhierarchy. Unlikeotherimplementations,cycles

are permitted. Thesoftwarehasnoinherent limitationonthenumber of nodesand

edgesasidefromthememoryandcpuspeedlimitations. Typical processingtimes

on aSparcstation 1

(approximately

12

MIPS)

areonlyafewseconds forgraphs

oflessthan100nodes andseveralhundrededgeseveniftheHP strategyrequires

(57)

3 FUNCTIONALSPECIFICATION 47

3.3

User

Inputs

Thegraphinput isafileofnodenames,initialpositions and

(typically)

a nodetype

andashape parameterwhich canbeusedin

defining

constraints. Constraints,HP

strategiesandother parameters and/or operationsarecontrolled

by

class methods

and variables specifiedinthemainprogram. Thevariables may beset

by

using

cinand cout C++ functions inconsole orfilecommand operationif desired.

Operationoftheprogrambegins

by

executing theprogram andthenresponding

withthefilename,etc. toqueries posed

by

theprogram.

3.4

User Outputs

Theprogramdisplaysare afunctionoftheclass callsthatformthemainfunction

oftheprogram. InadditiontothePostScriptoutputfile

data,

testdataandcrossing

countnumbersmay beoutputasappropriate. The PostScript outputfilecanthen

besenttoaPostScriptprinterfor hardcopiesofthegraphical output.

Alternatively,

(58)

4

Proof

of

Performance

4.1

Basic Directed

Hierarchy

Aproperdirected

hierarchy

whichhasnotbeensubjecttocrossingcountreduction

isshownin figure 21. Thesame

hierarchy

aftercrossingcount reductionisshown

in figure 22. A moredetailed discussion ofcrossingreduction inthis directed

graphfollows insection5.

Inorderto demonstratetheinsertionof

dummy

nodesandtheapplication of

constraintsto thecrossingreductionproblem,a morecomplexdirectedgraphthan

figure 2 1isrequired. Thedirectedgraphoffigure 14hasamix ofcircle andsquare

nodes where the square nodes wererandomly chosen tobeabout 25percent of

the total number of nodes. Thegraph hasatotal of35 nodes

(

eight of which

aresquares) arrangedin fiveranks of seven nodes each. A.2edge

density

factor

resultedin 52edges and133crossingsinitially.

4.2

Dummy

Node

Generation

The crossingreduction method requiresthat thegraphbeproper,ie. thatanylink

(59)
[image:59.482.150.352.123.265.2]

4 PROOF OF PERFORMANCE 49

Figure 1 4: A directed graph withtwo typesofnodes, circles andsquares,

(60)

additional nodes called

dummy

nodeswithappropriatelinkpairs areadded onthe

intermediate levels.

Oneexampleoftheneedfor

dummy

nodesisshowninfigure 15. Aspart of

aconstraint examplewherethecirclesand squares mustbeon separateranks, the

initial directedgraph offigure 14 has beenexpanded. Nowthecircles andsquares

are on separateranks,asrequired,butthedirectedgraphisnolongerproper.

Dummy

nodes, designated

by

triangles, have been added to the graph in

figure 16. Although

dummy

nodesmaybeaddedto thedirected graphsothat the

revised graph willbe both proper and

homeomorphic,

hereadifferentapproach

has beentaken. The

dummy

nodes neededtomakethegraph proper are placedin

thenearestempty locationwithintheappropriaterank ontheimplicit grid ofthe

graph representation. Thisis

highly

likelytoincreasethenumber ofedge crossings

initially. Noattemptis madetomaketherevised graphhomeomorphic withthe

initialgraph. Regardlessofhowthe

dummy

nodes are

inserted,

homeomorphicity

(61)
[image:61.482.166.368.118.421.2]

4 PROOF OF PERFORMANCE 51

Figure 15: The directed graph offigure 14 after squares are separated

(62)

Figure 16: The directedgraph offigure 14after separation andthendum

[image:62.482.36.451.112.421.2]
(63)

4 PROOF OF PERFORMANCE 53

4.3

Directed Graphs

with

Constraints

4.3.1 CirclesandSquaresonDifferent Levels

Theinitial directedgraphusedtodemonstrateconstrainededgecrossingreduction

(where circles and squares are required to be on different ranks) is shown in

figure 14. Intermediatesteps areshownin figures 15and16.

Only

twoHPpasses

oftherecommendedtype{'multiple'tobe discussed insection

2.5)

were required

togivetheresultsshownin figure 17.

Afterthesquares and circles are put on separate ranksand

dummy

nodes are

inserted,

thenumberofcrossingshasgrownto 147. Withthecrossingreduction

processcomplete,only51remainforacrossingreductionefficiency,ie. crossings

eliminated divided

by

147,

of.65. The details ofthis edge crossingreduction

efficiencymetric arediscussed insection5.1.

Aspreviously noted,furtherprocessing,outsidethescope ofthis work,could

nowbeappliedtothegraphinorderto simplifythefigure.

Especially

usefulhere

wouldbeminimizingthebends alongedges asthe triangles (ie.

dummy

nodes)

were replaced with simple point vertices. Themajor questiontounderstandis how

toslidethenodesalongeachrank, minimizingbendsyetmaintaininga compact

(64)
[image:64.482.33.449.106.417.2]

Figure 17: Completed edge crossing reduction of the directed graph of

figure 14 under the constraint that circles and squares be on different

(65)

4 PROOF OF PERFORMANCE 55

4.3.2 Squaresbefore CirclesontheSame Level

Figure 18 shows the result ofconstraining the graph in figure 14 to have the

squaresbeforethecircles onthesamelevel.

Surprisely,

inthisparticularexample,

reordering each rank so the squares comebefore the circles reduces the initial

crossingcountfrom 133to100. Sincethegraphis originallyproper,nodummies

are added as reordering nodes on each rankdoes not affect this graph property.

The constraint is defined so that if

dummy

nodes were required, they couldbe

interspersedwithinbothsquareand circle nodes on each rank.

Figure 19 showsthedirected graphwiththesquaresfirstconstraint afterthe

crossingreductionprocess.

Only

a.42efficiencywas achieved(seesection

5.1),

reflectiveofthedecreased

flexibility

in

deciding

node placementdueto thecon

straint.

4.3.3 Nodesthathave Fixed Locations

Acommonconstaintisthatsome ofthenodes must remainin fixedpositions. For

example, a graph layoutmight require thatcertain nodesbe fixed inthe middle

ofthegraphinorderto showthemainflowof a set oftasks.

Holding

the square
(66)

Figure 18: The squaresfirst directed graph after rearrangement so that

[image:66.482.165.369.109.252.2]
(67)

4 PROOF OFPERFORMANCE 57

Figure 19: The squares first directed graph after

crossing

reduction is [image:67.482.167.370.121.266.2]
(68)

graphis

initially

proper, there is no need to add

dummy

nodes before reducing

thenumber of edgecrossings. Thegraph afterthecrossingcountisminimizedis

shownin figure 20. The initialcountof133crossings has beenreducedhereto

just 61 evenwiththefixedsquare nodes constraint.

Acareful examination ofthefinalgraph shownin figure

20,

however,

shows

thatthecrossingcount canbereduced

by

atleastsevenmore crossings! Ifnode

1-1were attherightendofthefirstrank, threecrossingswouldbeeliminated and

ifnode6-2 wereatthe leftedge ofthesecondrank, four morecrossings could

beavoided. Thesechangeslook like theyhave beenmisseddueto thedirectional

properties ofthealgorithm whicharediscussed inthenext section.

5

Analysis

Inan earliersection itwas shownfora pathological casethatsomeHPsbecame

effectively useless in reducing crossing counts. But 'real world'

instances may

not bethe same. Moreover, other complexities may occur which will obviate

proposedpreferredHPstrategies. Twotechniques willbeused priortomakinga

formalrecommendation foranHP. Onewillbeadetailedperformancestudyof a

(69)

5 ANALYSIS 59

[image:69.482.167.369.121.264.2]
(70)

Figure21: The basetestcasewith64 nodes, 1 01 edges and282crossings

[image:70.482.144.376.189.431.2]
(71)

5 ANALYSIS 61

5.1

A

Crossing

Reduction

Efficiency

Metric

Ametricisneededtoevaluatedifferent HPstrategies. Althoughusingthenumber

ofcrossings eliminated would suffice asthemetric for a single graphanalysis,

therawnumberisnotmeaningfulforcomparisonsthatincludemultiple graphs.

If the absolute minimum number ofcrossings for each graph were known or

calculable,itcouldbeusedtonormalizetheresultsforeachgraph. However,this

isnotgenerallypossible. Asnotedearlier,

finding

theminimum number ofedge

crossingsof adirectedgraphisanNP-completeproblem[EMW85].

An alternative is to normalize using the inital crossing count, ie. an edge

crossingreductionefficiencymetric. Asa practicalmetric,thiswillavoidtheraw

scorescalingproblemallowingcomparisonsamongsimilartypesof graphs. But

a metric alone is not sufficient. It mustbe used with an appropriate set oftest

graphs. As did Eades and

Kelly

[EK86], a sequence ofgraphs with

increasing

edge

density

was used foreach ofthegraphtypes. Inorderto showtrendsrather

thanpossiblyabnormalexamples,a set of graphs was usedforeachdensity.

The validity ofthe metric is still open to question until it is compared to a

metricbasedontheabsolute mininmumnumber ofcrossingsforeach graph. If

(72)

crossingsinthe graph,andEthenumber of crossingseliminated, therelationship

between

T,

CandEisalways

0<C <T-E<T (10)

When E ~

0,

ie. few crossingshave been eliminated, T E ~ T. The

relationship between i? and C is unknown. Thevalidity ofthe metric is still

indeterminate. However,whenE ~T,T E~ 0

andthereforeC~ 0must

also

betruewhichimplies E~ C. Therefore,whenthe

crossing efficiencyiscloseto

1.0,themetric approximatesonewhichusestheabsolute numberof crossingsfor

normalization.

Anexample ofusing thismetricis shownin figure 23. Since theresults of

testingaset of graphs areplotted,ratherthan theresultforasingletest,themetric

becomestheaveragecrossingefficiency. The efficiency is higher forgraphswith

fewedge crossings (ie. lowedge

densities)

andbecomes 1.0whenall crossings

areeliminated.

Ifthegraph

initially

hadtheminimum number ofcrossingspossible, then there

wouldbenofurtherimprovementandthecrossing efficiencyreduction wouldbe

(73)

5 ANALYSIS 63

theHPstrategy,notthequalityofthegraph.

The initial crossingcount alwaysiscalculated after

dummy

nodes,ifany,are

added.

5.2

Comparison

of

Hierarchical Pass Strategies

5.2.1 A Single Example

Inordertoillustrate thedifferences between HPstrategies, atypicalhierarchical

graph, generated

by

the daterprogram, was used. Figure 21 showstheinitial

hierarchy. The daterparametersforthisexampleincludedeight nodes on a rank

and atotalofeightranks. Sinceeach node couldpotentially haveanedgetoeach

ofthenodesintherankbelow

it,

therearepotentially 8x8x7= 448edges for

this hierarchy.

Using

equations 5-9, suchamatrix wouldhave 5488 crossings.

Herea.2randomlink

density

produced 101 edgesand282crossings.

A single forward/down HPreduced the crossing countonlyto 271. Even

afterthe sixth successive

forward/

down HPthecrossingcounthad only gone

downto 159. More HPsofthisform didnot reducethecountany further.

Surprisingly,successiveback

/up

HPsresultedina minimumofonly 117cross
(74)
[image:74.482.143.375.191.432.2]

Figure 22: The base testcase after six

back/up

HPswith only 117edge
(75)

5 ANALYSIS 65

surprising becausethistypeofHPhas thesame problemasthe

forward/

down

HPstrategy. Both disturb thenode orderthattheprevious level pass had used

toreduceits crossing count. Unlikethepathological casedescribedearlier, this

time thisstrategy doeswork. AsdifferentHPstrategies arelookedatforthistest

case, theresultfromthe

back/up

successive HPs strategy looksquite goodbut it

requires sixHPstoreach a minimum.

As indicated in section 2.4 there are only four basic level pass methods

forward/down,

forward/up,

back/up

andback/down. Two HP strategies that

mightyieldbetteror equal results quicker werehintedatinsection2.5. Bothare

basedon the toothpaste tube squeezinganalogy. The firstadditional strategy is

themethodmiddle,whichisa single pass algorithm. Thesecondstrategy, called

multiple,isthebestcombinationofthefour basicsinglelevelpassmethods.

Themiddle algorithmstartsat an appropriatemiddlerank andsqueezes cross

ingsoffthetopofthedirectedgraph

by

going

forward/up

andoffthebottom

by

goingback/down. Th

Figure

Figure 1 : A directed graph with edge crossings.
Figure 2: The directed graph of figure 1 with nodes rearranged to minimize
Figure 3:crossingsThe directed graph of figure 1rearranged to minimize edge with the constraint that on any level the squares must be to theright of the circles on the same rank.
Figure 4: Topological possibilities for two edges, (a) Edges that cross, (b)Edges that do not cross.
+7

References

Related documents

These wines are hand-selected by our wine list architect and reflect the best and truest representation of the various wine regions where they are produced.. Both of these

Thus, BMIs could address different degrees of alcohol use and problems by serving as a stand-alone intervention for people with less severe alcohol prob­ lems or as an

Finally, it is worthwhile to say that due to contradictory findings on the correlations between extraversion/introversion and oral performance including fluency, accuracy,

Comparing the exposure of a daily dose of 3 g/day of inulin from food supplements with the inulin doses of 5 g/day and 10 g/day considered to be without appreciable risk for most

Consequence modeling revealed that the main hazards of hydrogen facility are the vapor cloud explosion (VCE), jet fire and flash fire, which jet fire will have most fatality and

Urine drug screening (UDS) provides objective data regarding patients who are managing chronic pain, and can be used to directly improve patient safety.. For their safety, it

To the extent that Designated Persons hold Commercially Sensitive Information, they are bound by the terms of this Code of Conduct in relation to that information and therefore

The granting of a permit does not presume to give authority to violate or cancel the provisions of any other state or local law regulating construction or the performance