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
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 specialexpertisewhichtheyhave generouslysharedwithme asthe thesisgrewfrom ill-formed ideas
intoreality. Throughoutthisprocessmywife,
Judy
has beenmostunderstandingAbstract
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. Thismethodisdirectly
directedgraphs
hierarchicalgraphs
graphlayoutalogrithms
edgecrossings
Computing
Review Subject
Codes
Primary: G.2.2Graph
Theory
Secondary: F.2.2NonnumericalAlgorithmsandProblems
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
131.4.3 Directed Graph
Drawing
.... 172 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
PassStrategy
342.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
484.2
Dummy
Node Generation 484.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
ReductionEfficiency
Metric 615.2.1 A Single Example 63
5.2.2 SetsofTest Directed Graphs 67
5.3
Crossing
Reductions Missed 725.4 Level Pass Anomalies 73
6 Conclusions 73
6. 1 Further Improvements 74
6.2 Thegeneralgraph . . . . 76
1 INTRODUCTION ANDBACKGROUND 1
1
Introduction
andBackground
1.1
Problem
Statement
Thisthesisdevelopsa methodofreducingtheedgecrossingcount of ahierarchical
graph. Themethod includestechniques forsituationswhichhaveconstraints on
nodelocations. Sincethealgorithmignorestheedge
directivity,
it isalso applicabletoreducingedgecrossingsinthegeneral graph.
1.2
Introduction
Ahierarchical ordirected graph consists of a set ofnodes and aset ofstraight
linesthatrunbetween pairsofnodes. The
lines,
whichinadirected graphhavean 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
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. Eachedgealsohasameaning, such asinaPERTchartwheretheyshowtheorderingoftasks. Inthe
PERTchart exampletheedgesusually haveadirection indicated
by
anarrowheadindicating
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 orhardcopy
device. The locationofthenodes inthe
display
fixes theend points ofthe edges. However, an arbitrarynodelayoutwill most
likely
resultinavisualizationthatconfusestheviewerratherthanenhances his/herunderstandingofthesystem
being
represented. The1 INTRODUCTION ANDBACKGROUND 3
viewertogainunderstandingofthesystem
being
modeledby
thegraph.Notionsofgraphreadability [TDBB88,
STT81]
aredifficulttoquantify. Placing
thenodes on arectilineargridismost often more aesthetically pleasingthena 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, thatedgecrossingminimization ispart ofhierarchical graphlayout algorithms. Oncethe
number ofcrossings has been reduced to an acceptable level (reduction to the
theoretical minimumisnot requiredfor readability
improvement)
otheraestheticconsiderationsmaybeapplied. Recent hierarchicalgraphprogramshave included
maximizingedge straightness
[STT81]
andminimizingedgelength[GNV88]
aswellas 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
Figure 1: A directed graph with edge crossings.
algorithm whichimplements it.
Specifically,
layout algorithms which attempttomaximizereadability have been developed forthegeneraldirectedgraph. Thisthe
sis proposes modificationsto thehierarchicalgraphlayoutalgorithm of
Sugiyama,
Tagawa,andToda
[STT81]
to allowthecase of constraints onthenode and edgelayout.
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 typesof nodes: squares and circles. The vertices are showninthree ranks orlevels
[image:14.482.128.354.105.266.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 animplicitdummy
node which willbe explainedlater.)
Ifwe require thatallcircles mustappear to theleftofanysquare within a
level,
then figure 3 shows one possiblesolution. Thisthesisproposes an algorithmthatgivenagraph suchas shownin
figure
1,
willproducealayoutsuchas shownin figures 2and3,
i.e. onewith a1.3
Previous Work
Thepreviousworkondirectedgraphs canbe benchmarked
by
tworecentliteraturesurveys of graphdrawing. Tamassia,DiBattista, andBatini[TDBB88] surveyed
theliteratureasbackgroundtogivingtheirapproachto thegeneral graph problem.
Subsequently,
Eades andTamassia[ET88]
issued an annotatedbibliography
onalgorithmsforgraphdrawing.
Before
looking
attheautomated computertoolsfor directedgraphdrawing,
itis 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], forexample, are ofthis class. While bothofthese are powerful
drawing
programs,theplacement of nodes andlinksis lefttotheuserwith,at
best,
backgroundgridinsertion 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'
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 handledstartingwithtreesand
becoming
moregeneral. WetherellandShannon[WS79],
Vaucher [Vau80], and Reinhold and Tilford
[RT81]
give solutions forthe tree [image:17.482.117.370.103.275.2]algorithm,certain additional constraints aretractable. For
instance,
iftheplanargraph 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 ofadirectedgraph,eveninthesimple case ofonlytwolevelswherethepositionsofthevertices
inone ofthelevels is
fixed,
has beenshowntobe NP-completeby
Eades, et al.[EMW85]. This does not mean that it is impossible to reduce the number of
crossings. Theniinimum numberof crossingsmay becalculated
by
permutingvertices andthencountingthenumber ofcrossingsforeachcombination.
Any
ofthe 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,
this1 INTRODUCTIONANDBACKGROUND 9
Theother approach stems fromthework ofWarfield
[War77]
indeveloping
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 orheuristicthatrearranges 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
count.
Almostno attentionhas beenpaidto theproblemof
laying
outahierarchicalgraph withconstraints. Gansner
[GNV88]
considersthecaseof edges ofdifferentweight inwhich thealgorithm places greater emphasis ontryingto shorten the
links ofhigherweight. Butthemore general problem ofapplyingconstraintsto
thelayoutofadirected graphhasnotbeenaddressed. Exampleapplications that
require constraints wouldbe
keeping
thecritical pathinaPERTchartverticallyaligned or
having
direct staffreports on adifferentrank than linereportsin anorganizationchart.
1.4
Theoretical
andConceptual Development
1.4.1 Directed Graph Description
ThenotationanddefinitionsusedhereinarethatofSugiyamaet al
[STT81]
whichfollowthatofWarfield
[War77]
with oneexception: hierarchies havetheir"roots'atthetopwhichis level 1. Asalreadynoted,adirectedgraph
G(V, E)
iscomposedof a set ofvertices, Vand a set of edgesE. So
far,
therehas beenno restrictionon wherethesetof verticesareplacedintheplane.
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 nsubsets as
v=
VAV2u---uvn
(vinvj
=9,i^j)
(D
givesan n level
hierarchy
withthesubsetVj
attheithlevel. Thenotation foradirectedgraph of nlevels is G=
(
V, E,
n) wheretheorderofthevertices withinalevel hasnot yetbeen described.
Foreachedge
e=
{vi,Vj)
GE,
withV{ GV;,
Vj GVj
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 onedgesbetween adjoiningvertices canberelaxedwithout mucheffort, andinthis
implementation it is another form of constraint.
Second,
all edges must pointdownward andthuscycles arenot allowed. Onceagainthisisoverly restrictive.
Someworkershaveused appropriatetemporaryarcdirectionreversalstoovercome
Theedge
(A, G)
offigure 1 spans morethanlevel,
iej
i > 1. Ifalledgesspan onlyone level then the directed graph
is,
by
definition,
a proper nlevelhierarchy.
Continuing
withtheformulationofSugiyama,thisisequivalenttostatingthatE =
E1UE2---\JEn.1
(EinEj
=$,iAJ)
(3)
where
E{
cVj
xVj+i,
i =1,
. . .,n 1. Notethatrequiringthat theends ofthe
edges in eachsubset
*,
comefrom adjacentlevels forces thehierarchy
to be aproperhierarchy.
Any
hierarchy
may be made into a properhierarchy 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 properby
theinsertion of vertexKonlevel 2 betweenvertices CandDwithedges
(A, K)
and(K,
G)
replacing1 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 onlyaffectedby
the orderingofthevertices and nottheirseparation. Eachlevelconsists of asubsetofvertices,
Vj, whose orderisa, = v\v2 v\v,\, where
|
V;
|
isusedtoexpress thenumberof 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. Inordertodecidewhichset a yields theminimal crossingcount, a methodisneeded tocountthe
numberof crossingsforagiven a.
[image:23.483.114.373.104.213.2]edges cross. Figure 4showsthetopologicalpossibilities.
Even inthesimplest caseoftwoedges
(u,
r)and(v,s),determining
whethertheedges crossis easytodo
by
eyebutmustbeexpressedmathematically. Whatisneededistoexpressthedifference betweenthecase offigure
4(a)
and(b). LetX(i)
bethexcoordinate of eachvertex. Rememberthat the actual valueofthex coordinates isnot
important;
onlytherelativeorderingof vertices within eachlevelmustbepreservediftheedge crossingsare tobeuneffected. Then, ifthe
sign of
T=(X(u)-X(v))(X(r)-X(s))
(4)
isnegative, theedges cross[EW89].
However,
theneedfora multiplication stepis 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-levelhierarchy
and(b)
its adjacencymatrix. Ingeneral1 WTRODUCTION ANDBACKGROUND 15
rowinthematrix
ir =
ri,r',...,rj,...,rfVi+i|
(5)
isasequenceofl'sandO's
indicating
whethertheithvertexinsequenceothasanedgethatgoesto thejthvertexinsequence at+\. Thenumber of crossings caused
by
theedges whichemanate fromtwovertices on the samelevelK{R\W)
isgiven
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)
toshowonlytheedgesforthecasei =
b, j
=c. Ifr=/
andp =h,
theproducty
=y
= i-i = i(7)
showsthat thesetwoedges cross and mustbe included inthesummation. Since
r{rp
istheproduct ofonly l's andO'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 vertexinVt+\
cannot cross.(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-levelhierarchy
and(b)
itsadjacencymatrix. Thehierarchy
[image:26.482.108.381.139.484.2]1 INTRODUCTIONAND BACKGROUND 17
sumover all pairs of verticesintandisgiven
by
ro1 m
(*)
=k(r,rW)
(8)
=1 j=i+l
andthe totalof allcrossingsCtotalinthenlevel
hierarchy
isgivenby
Ctota,
=c(t).
(9)
1.4.3 Directed Graph
Drawing
As previously
indicated,
thealgorithmfordrawing
directed graphs hastwosegments. Thepurposeofthefirstpartistomakethegraph a properhierarchy.
Previousdirectedgraphlayoutalgorithmshavenotincluded layoutconstraints.
Whenthedirectedgraphlayout includesa constraintthatrequires nodes ofdifferent
typestobeon separateranks,theseparationis best donepriortomakingthegraph
proper. Iftheimplementation ofthisformof constraintis delayeduntil afterthe
hierarchy
isproper,thegraphis verylikely
nottobeproper aftertheconstraintisimposedand willhavetobemade proper again.
Anexampleofthis typeof allowed constraintisthatcircle and square nodes
mustbeonalternatelevels. Figure6isthedirected
hierarchy
offigure 1withthismodification. Intheredrawingnew edgecrossingsmayoccur.
Figure 6: The
hierarchy
offigure 1 with theadded constraint thatcircles1 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)),
onecrossingcouldbeeliminated withoutchangingtheorderingofthenodeswithinalevel. Asimilar
situationinvolvesedge
(F, G)
.Thispotentialambiguity isresolved oncethe
hierarchy
ismadeproperasthehierarchy
offigure 6 has been in figure 7.Crossing
amongedges thatoriginateamongnodes on adjacent ranks cannotbeaffected
by
theabsolutexposition ofthenodes. Someattentionisrequiredto the
dummy
nodeinsertionprocess. Theopennumbered square nodes aretheadded
dummy
nodes.Separating
adjacent nodeswithin 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 likeregularnodesinthereorderingalgorithm. Inthisimplementationa
dummy
nodemay haveFigure 7: The
hierarchy
offigure 6afterdummy
nodes have been added1 INTRODUCTIONAND BACKGROUND 21
dummy
nodes could alsobeusedtoreduce graphcomplexityby
collapsingseveralnodesandtheirconnectingedgesintoonenode; then theremightbemorethantwo
edges connectedto the
dummy
node. This collapsingintoone nodetechniquehasbeenused as a methodof
deleting
cyclesfromthegraph;inthisimplementationcycles are allowed. Bends intheimplicitreal edgetakeplace at
dummy
nodes;thiscanbeusedinroutinesthatimprove readability
by
modifyingthebendshapeorlocationaftertheedgecrossingreductionprocess.
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. Leveloneisappropriateifthere 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
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 itstillhadthecomputational expenseproblem. Thesedirectmethods areonlyusedtocheck
theresultsoftheindirectmethodinsmall examples.
Eades and
Kelly
[EK86]
used adifferent but stilldirectmethod with severalvariations. All are sorting schemes,
(greedy
insertion,
greedy switching andsplitting), based on minimizing the total crossingcountbetween thetwolevels
being
adjusted. Firstonelevelissorted andthen theotheris doneuntilnofurtherreductionis gained. Theirperformance testsshow results similartoSugiyama's
averaging indirectmethod. Althoughtheyonlytestedtwolevel
hierarchies,
theirmethods canbeusedin larger hierarchiesas willbeexplainedlater.
The indirect method was developed
by
Sugiyama[STT81]
and has sincegivenbirthtoseveral variants[RDM+
87]
[Mey83][Dav85] [GNV88]
[TDBB88]
[Sug87] [EK86]
[ET88]. The basicconceptis tokeep
a vertexin level i 'near'ver-1 INTRODUCTIONAND BACKGROUND 23
ticesare, theless likelytheiredgewillcrossanother edge. That
is,
infigure 7 ifvertexFwere nearervertexlO,theless
likely
edge(F,
10)
wouldcrossanyotheredge.
Using
theindexvx,i.e. thexcoordinate ofthevertexasthemeasureofitspositionwithintherow,themethodtranslates to
having
the xcoordinate ofthevertexin 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 theoptimalnumber 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 ofnodeswithinarankis goingtobe relativelysmall,i.e. ontheorderoftensof nodes ratherthan
thousands perlevel. Except forthe initial pairings of
levels,
eachrank willbecloseto
being
orderedeachtimeitneedstobesorted.Aspart ofthewithin-levelorderingprocess,thisthesisaddsthepossibilityof
including
level order constraints. Eitherthe xposition calculation orthesortingwhere 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 upthe
hierarchy
forafixed number of passes or until there was nocrossing countreduction, whichever camefirst.
Only
afewpasses, usuallylessthanfive,
werethemaximumattempted. On thedownwardphase, level i was sorted andlevel
i 1 was fixed ('down
barycenters')
andon the upward phase level i + 1 wassortedandlevel i washeld fixed
('up
barycenters'). Variousalternatives, suchasaveragingtheupanddown barycenters have beenused,buttests
[GNV88]
havenot suggestedthatone methodis far betterthananother. This isthemost empirical
part ofthealgorithm.
Afterthecrossingreductionprocess,mostdirectedgraphalgorithms add other
readability improvementoperations.
Typically
astraighteningalgorithm isusedto takeout excesskinks ineach edge. Sometimesthisis followed
by
analgorithm2 IMPLEMENTATION 25
2
Implementation
2.1
Additional Requirements
Thisthesis presentsimprovements and extensionsto heuristics which minimize
thenumber of crossingsinthehierarchicalgraph
drawing
problem. As suchtheimplementation does not needto concern itselfwithsome ofthe preprocessing
andpostprocessingstepsrequired ofa completedirectedgraph
drawing
package.Theimplementation must,
however,
facilitatethe incorporationof extensionswhich 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
acprocess. 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 levelreordering process. Here, and for other constraints ofthis
form,
a method ofrebuildingthe
hierarchy
accordingto theconstraintprescription priorto crossingcountreductionisrequired.
The implementationshouldalsoberobust. That
is,
itshouldbeabletohandlegraphs 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 andthose that
display
thegraphrepresentation.2.2
Tools
2.2.1 Hardware
Thesoftware associated withthis thesishasbeen developed onSunworkstations
2 IMPLEMENTATION 27
hardcopy
output, either listings orfigures. Theequipment was interconnectedover anextensive ethernetwhichruns alarge varietyofprotocols,
including
XNSandTCP/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,
butinitially
1.2)
enabledtheuse of an object-oriented style.
Arequired adjunctwassome methodfor
displaying
thegraphsboth beforeandaftercrossingreduction. Whilemanualplottingthegraphswouldhavegiventhe
required
information,
itwouldhave rapidly becomeatediousprocess. Publicationqualityprinted graphs
hardcopy
printed also were neededforthis thesis. Tomeetboth goals, functions were written that generate PostScript descriptions ofthe
graphs. Eithertheworkstation's windowingsystem and aPostscriptpreviewer or
aprinterthatunderstandsPostScriptwas usedfor
displaying
thesegraphs. Other2.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
countedintheoverallstructure sinceitwillbeontheedgelinkedlist forthenode ateachendof
2
IMPLEMENTATION
29head
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]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 ascendingindex order and node pointers fora rank are storedin
increasing
order oftheirordinate.
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
2 IMPLEMENTATION 31
2.4
Cross Count Reduction
Method
Thefirstchoicein
deciding
onthecrossingcount reduction methodis inchoosingbetweenadirectorindirectapproach. Eades [EK86,figure
3]
hasshownthatfor low edgedensities,
anaveraging(indirect)
technique produces fewer crossings.However, at higher densities the results are essentially the same as the greedy
switching
(direct)
method.However,
ifspeedisimportant,
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 singleadjacencymatrixcalculation. Forn>2theadjacencymatrix mustberecomputedeachtimeapair of
levelsischosenfor crossingcount reduction. Additionally,foreach proposedswap
of nodesinthegreedyswitchingprocess, thecrossingcount mustbecalculatedin
ordertocheckiftheswapwould resultinareducedcrossingcount.
theadjacencycalculation andtheneedfor
including
constraints indicates greedyswitchingasthemethodofchoice.
Greedy
switchingcanbeconsidered analogoustoabubblesort. 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 processthathadstarted withlevelspairedstartingatthebottom (here level
5)
withlevelabove(4)
held fixed. Thiswouldbeconsideredpairing
by
going backfacing
up. With theappropriatechoice ofstartinglevel,therearefourcombinations,
forward/down,
forward/up,
back/up
andback/down.Attheinstance
during
thissequenceillustratedby
figure7,nodes withinlevel2 are going tobe swappedin orderto nrinimize thecrossings between level 1
(nodes A and
B)
and level 2 (nodes1, 2,
D,
3 and4). All the nodes in level 1(andall nodesin levels 3or
higher)
areheld fixed. Changes inthecrossingcountbetweennodesin level 2andlevel 3as aresult ofthenode exchanges withinlevel
2 IMPLEMENTATION 33
Theproblem centers around nodeD in level 2.
Ideally
node 1(ignoring
wherenode Cshouldgo)shouldbe betweennodes 3and4orafter4.
Swapping
nodes1 and2reduces thelevel 1-2crossingcount
by
one so theswap will be carriedout. Butwhenthetimecomesto testswappingadjacent nodes 1 and
D,
thereisno 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, anincreasein computingtime. Notethatin boththesimple greedyswitch andthemodified
greedyswitchimplemented
here,
morethanone passisrequiredtopercolatethenodes to thepositions whichreflecttheminimumcrossing count.
However,
themodifiedgreedyswitchrepresentsa significantimprovementovertheworst cases
ofthesimplegreedyswitch. Intheworsecaseforthesimplegreedy switch,like
thebubblesort, a nodeattheopposite endfrom its desiredpositionismoved
by
swappingon placeat atime
by
adjacent node swapping. Inthemodifiedgreedyswitch,anode can movemultiplepositionsinoneswap,possibly
taking
onlyoneswaptogettowhereit 'belongs'.
oftwonodes at atimeare affected. Node 1cannotgettoits 'desired' place
by
asimple swap.
Checking
a complete set of all combinations ofnodes on onelevelisconsidered onepass. Since it isnotknown howmanypasses are required until
a pair oflevels produce acrossing count minimum, passes are repeated until a
passfailstoproducea reductioninthecrossingcount.
Specifically
not consideredaretheeffectsonadjacentcrossingcountsandthepossibilitythatswappingnodes
whichproduce no changein crossingcount mightleadtoan eventuallowercount
forthepair oflevels.
2.5
Hierarchy
Pass
Strategy
Asnotedinthepreviousdiscussion,therearefour basicmethodsof
doing
a setoflevel crossingreductionsforan entire
hierarchy,
i.e. ahierarchy
pass(HP). Variouscombinations have beensuggested [STT81,
RDM+87, Car80]
and an estimate ofthenumber ofHPcyclestousegiven,butnoanalysishas beenproposed.
Among
thesuggested strategiesarerepeatedHPdownandalternating downandup. An
indication ofhow manyHPsare required usingthese strategies canbe seen
by
looking
atfigures 10-12.2 IMPLEMENTATION 35
(a) (b) (c) (d)
Figure 10:
(a)
Before anyhierarchy
passes and level reductions,(b)
Afterfirstforward/downonlevel 1.
(c)
Another forward/downonlevel 2. [image:45.482.95.393.212.410.2]6
6
6
6
(a)
(b) (c) (d)Figure 11:
(a)
After the forward/down pass on level 4.(b)
After thestart ofthesecondHPwitha
forward/
down pass onlevel 1.(c)
After the forward/downpass onlevel 2ofthesecondHP.(d)Aftertheforward/
downpass 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 levelpasses on each levelareshown in figures
10(b)
through 11(a). Notethat after acompleteHP onlyasinglecrossinghas beeneliminated; theeffect ofeverylevel
pass afterthefirst has just beentomovetheuncrossedpointdownthehierarchy.
Theresults oftheindividual levelpassesforthesecond set offorward/down
[image:46.482.89.398.80.309.2]2 IMPLEMENTATION 37
<B
o
o
(a) (b) (c)
Figure 12:
(a)
Thefirstforward/
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 arecounter examples which showthisassumptiontobe invalid.
Only
one level pass ofthe third HPchanges thehierarchy
at all. Thestatusafterthe third HP is complete is shown in figure 12(a).
Only
the second levelpass ofthe fourth HPchanges the
hierarchy
astheremaining crossing ismovedupasseeninfigure 12(b). A fifth
HP,
thesamenumberasthenumber ofranks,is [image:47.482.133.354.100.309.2]the
hierarchy
withoutanycrossings.Surprisingly,
forthis example,alternatingforward/
downandback/up
HPscan require more HPs thanjust successive forward/down HPs. As indicated
earlier,thecompletion ofa
forward/
downHPis showninfigure11(a). Nowaback/
upHPatthispointistopologicallythesame asbeing
atfigure10(b),exceptfor the node labels.
Completing
the back/up
HPwould result in figure11(a)
whichisthesame asthestart ofthisHPexcept upsidedown. Thenthe thirdHP,
a
forward/
downsetwouldbeginatthestageoffigure10(b)
again! SuccessiveHPunderthealternatingscheme onthisexamplefailtogivetheknownminimum
solutionyielding only a slight improvementoverthe original crossing countin
reducingit only
by
1 !An analysis oftheproblemindicatesthat
forward/up
andback/
down HPsaresurprisinglymore efficientin reachinga relativeminimumtotalcrossingcount.
Asingle
forward/up
orback/downHPmust yieldalocalminimum. Althoughusingeitherofthese twomethodsis
likely
to increasethecrossing countinthelevel pair thatfollows eachstep intheHP, a secondHP usingthesame method
producesnochanges! Away tolookatthisisto thinkofthisas atubeoftoothpaste
being
rolledup fromthebottom,
pushing theknotof crossingstoward theedge at2 IMPLEMENTATION 39
HP beginsatlevel
2,
adjustingtheposition ofCandDinordertominimizethecrossingswithlevel 1 nodesAandB.
(
Aforward/downpass atlevel 1 couldhave been doneto takeadvantage ofadjusting level 1 nodesalso).
Rearranging
the level 2 nodesin ahierarchy
with more nodes ateach levelis likely tohavemade thecrossingcountbetween level 2and3 worse, although
in this case it makes things better. But once the
forward/up
pass is done atlevel two, thenextstep in theHPwill not affect therelationship between level
1 andlevel 2. Notethatthis is different fromthe
forward/
downHPtechniquedescribedearlier. Another
forward/up
completeHPwillfind level 1 andlevel2unchangedfromthefirst HPandany improvementthatcouldbe done has been
done already! This is nottostate thatno further improvements are possible; a
down
facing
HPmightpossiblyfindan evenlowerrelativeminimum,butsinceitwill affect changes made
during
thepreviousHPthingscould getworse. Giventhat there aretwo typesofdown
facing
HPs,
once again, the onethatsqueezescomplexity alongthe
hierarchy
aheadofit,
i.e. back/downmightbe desirable.Inordertomore
fully
explorethepossibleHPsequences, thesoftwarehas beenimplementedthatdoesanyofthepossible combinationsdiscussedabove plusany
individualpair of adjacentlevels
facing
ineitherdirection. Oneinteresting
possiblesoftware 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), addingdummy
nodes, countingcrossings,etc. Browsisnotderived fromNodeListalthoughthisclearly isan alternativeformulation. Atthetime theseclasseswere
being
implemented,
multiple inheritance was notavailable inthe 1.2version ofCfront,theAT&T C++translator. Since bothnodefunctionsand
displaying
functionsweredesired in Brows, itwas unclear whichtypeofbase class shouldbe developed. Instead,the technique ofusinga private pointertoaninstanceofthe
'base'
classisused. Ifnecessary, thisallows a classtohavemultipleinstancesof
2 IMPLEMENTATION 41
2.7
Data
Generation
Test hierarchical graph data has been generated
by
two methods. Thefirst ismanuallywritinganinput file.
Only
smallhierarchies(
typicallylessthanadozentotalnodes on all
levels)
are practicaltoimplementby
hand. However,thiswasthe technique of choiceto
debug
the software as each function was developed.Testcaseswereconstructedthatcheck rankordering,
dummy
node generation andinsertion,
etc.Performanceand analysisofthesystemrequiredlarger hierarchiesand random
placements. Intheseinstances aseparatedatagenerationprogram, dater,pro
ducedtherequiredinput files. Parameters includedthenumberof ranksdesired,
nodes per rank and
density
oflinks andthenumberoftestcases desired. Shapefunctionswerebuilt insothathierarchieswiththesame number of nodes on each
rank, the samenumber of nodesas the rankindex (i.e. linear
increasing),
etc.couldbegenerated.
2.8
System OrganizationAnoverall perspective ofthesystem organizationisshownin figure 13. Testcases
display
filegeneration program. Ifthereareconstraintstheyaredefinedasseparatemoduleswhichare referenced
by
themainprogram. Thegraphs associated with aparticulartestcanbeviewedviathePostScript
display
previewer or viahardcopy
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 PostScriptdisplay
ofthe graph may begenerated. After the graph is proper,
ie,
any neededdummy
nodes have been2 IMPLEMENTATION 43 Test Case Generation Constraints Graphs
Crossing
Reduction andPlotting
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]The most
interesting
parts ofthe algorithm are included in the level pairreduction 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. Theprocedure 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
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
alogicalandasindicatedfollowing
equation7probably 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
orusedasinputtoaPostScript
display
previewer. Theprogram can alsobe settoproduce anoutput
listing
ofnodes,edgesand coordinates. Several differenttypesofconstraintshave 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),edgedensity
factorandnumberofdirectedgraphsdesired.
3.2
LimitationsandRestrictionsTheinput isassumedtobea validhierarchy. Unlikeotherimplementations,cycles
are permitted. Thesoftwarehasnoinherent limitationonthenumber of nodesand
edgesasidefromthememoryandcpuspeedlimitations. Typical processingtimes
on aSparcstation 1
(approximately
12MIPS)
areonlyafewseconds forgraphsoflessthan100nodes andseveralhundrededgeseveniftheHP strategyrequires
3 FUNCTIONALSPECIFICATION 47
3.3
User
Inputs
Thegraphinput isafileofnodenames,initialpositions and
(typically)
a nodetypeandashape parameterwhich canbeusedin
defining
constraints. Constraints,HPstrategiesandother parameters and/or operationsarecontrolled
by
class methodsand variables specifiedinthemainprogram. Thevariables may beset
by
usingcinand cout C++ functions inconsole orfilecommand operationif desired.
Operationoftheprogrambegins
by
executing theprogram andthenrespondingwiththefilename,etc. toqueries posed
by
theprogram.3.4
User Outputs
Theprogramdisplaysare afunctionoftheclass callsthatformthemainfunction
oftheprogram. InadditiontothePostScriptoutputfile
data,
testdataandcrossingcountnumbersmay beoutputasappropriate. The PostScript outputfilecanthen
besenttoaPostScriptprinterfor hardcopiesofthegraphical output.
Alternatively,
4
Proof
ofPerformance
4.1
Basic Directed
Hierarchy
Aproperdirected
hierarchy
whichhasnotbeensubjecttocrossingcountreductionisshownin figure 21. Thesame
hierarchy
aftercrossingcount reductionisshownin figure 22. A moredetailed discussion ofcrossingreduction inthis directed
graphfollows insection5.
Inorderto demonstratetheinsertionof
dummy
nodesandtheapplication ofconstraintsto 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 whicharesquares) arrangedin fiveranks of seven nodes each. A.2edge
density
factorresultedin 52edges and133crossingsinitially.
4.2
Dummy
Node
GenerationThe crossingreduction method requiresthat thegraphbeproper,ie. thatanylink
4 PROOF OF PERFORMANCE 49
Figure 1 4: A directed graph withtwo typesofnodes, circles andsquares,
additional nodes called
dummy
nodeswithappropriatelinkpairs areadded ontheintermediate levels.
Oneexampleoftheneedfor
dummy
nodesisshowninfigure 15. Aspart ofaconstraint examplewherethecirclesand squares mustbeon separateranks, the
initial directedgraph offigure 14 has beenexpanded. Nowthecircles andsquares
are on separateranks,asrequired,butthedirectedgraphisnolongerproper.
Dummy
nodes, designatedby
triangles, have been added to the graph infigure 16. Although
dummy
nodesmaybeaddedto thedirected graphsothat therevised graph willbe both proper and
homeomorphic,
hereadifferentapproachhas beentaken. The
dummy
nodes neededtomakethegraph proper are placedinthenearestempty locationwithintheappropriaterank ontheimplicit grid ofthe
graph representation. Thisis
highly
likelytoincreasethenumber ofedge crossingsinitially. Noattemptis madetomaketherevised graphhomeomorphic withthe
initialgraph. Regardlessofhowthe
dummy
nodes areinserted,
homeomorphicity
4 PROOF OF PERFORMANCE 51
Figure 15: The directed graph offigure 14 after squares are separated
Figure 16: The directedgraph offigure 14after separation andthendum
[image:62.482.36.451.112.421.2]4 PROOF OF PERFORMANCE 53
4.3
Directed Graphs
withConstraints
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
twoHPpassesoftherecommendedtype{'multiple'tobe discussed insection
2.5)
were requiredtogivetheresultsshownin figure 17.
Afterthesquares and circles are put on separate ranksand
dummy
nodes areinserted,
thenumberofcrossingshasgrownto 147. Withthecrossingreductionprocesscomplete,only51remainforacrossingreductionefficiency,ie. crossings
eliminated divided
by
147,
of.65. The details ofthis edge crossingreductionefficiencymetric arediscussed insection5.1.
Aspreviously noted,furtherprocessing,outsidethescope ofthis work,could
nowbeappliedtothegraphinorderto simplifythefigure.
Especially
usefulherewouldbeminimizingthebends alongedges asthe triangles (ie.
dummy
nodes)were replaced with simple point vertices. Themajor questiontounderstandis how
toslidethenodesalongeachrank, minimizingbendsyetmaintaininga compact
Figure 17: Completed edge crossing reduction of the directed graph of
figure 14 under the constraint that circles and squares be on different
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 couldbeinterspersedwithinbothsquareand circle nodes on each rank.
Figure 19 showsthedirected graphwiththesquaresfirstconstraint afterthe
crossingreductionprocess.
Only
a.42efficiencywas achieved(seesection5.1),
reflectiveofthedecreased
flexibility
indeciding
node placementdueto theconstraint.
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 squareFigure 18: The squaresfirst directed graph after rearrangement so that
[image:66.482.165.369.109.252.2]4 PROOF OFPERFORMANCE 57
Figure 19: The squares first directed graph after
crossing
reduction is [image:67.482.167.370.121.266.2]graphis
initially
proper, there is no need to adddummy
nodes before reducingthenumber of edgecrossings. Thegraph afterthecrossingcountisminimizedis
shownin figure 20. The initialcountof133crossings has beenreducedhereto
just 61 evenwiththefixedsquare nodes constraint.
Acareful examination ofthefinalgraph shownin figure
20,
however,
showsthatthecrossingcount canbereduced
by
atleastsevenmore crossings! Ifnode1-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
5 ANALYSIS 59
[image:69.482.167.369.121.264.2]Figure21: The basetestcasewith64 nodes, 1 01 edges and282crossings
[image:70.482.144.376.189.431.2]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 ofedgecrossingsof 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 withincreasing
edge
density
was used foreach ofthegraphtypes. Inorderto showtrendsratherthanpossiblyabnormalexamples,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
crossingsinthe graph,andEthenumber of crossingseliminated, therelationship
between
T,
CandEisalways0<C <T-E<T (10)
When E ~
0,
ie. few crossingshave been eliminated, T E ~ T. Therelationship 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 crossingsareeliminated.
Ifthegraph
initially
hadtheminimum number ofcrossingspossible, then therewouldbenofurtherimprovementandthecrossing efficiencyreduction wouldbe
5 ANALYSIS 63
theHPstrategy,notthequalityofthegraph.
The initial crossingcount alwaysiscalculated after
dummy
nodes,ifany,areadded.
5.2
Comparison
ofHierarchical Pass Strategies
5.2.1 A Single Example
Inordertoillustrate thedifferences between HPstrategies, atypicalhierarchical
graph, generated
by
the daterprogram, was used. Figure 21 showstheinitialhierarchy. The daterparametersforthisexampleincludedeight nodes on a rank
and atotalofeightranks. Sinceeach node couldpotentially haveanedgetoeach
ofthenodesintherankbelow
it,
therearepotentially 8x8x7= 448edges forthis 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 gonedownto 159. More HPsofthisform didnot reducethecountany further.
Surprisingly,successiveback
/up
HPsresultedina minimumofonly 117crossFigure 22: The base testcase after six
back/up
HPswith only 117edge5 ANALYSIS 65
surprising becausethistypeofHPhas thesame problemasthe
forward/
downHPstrategy. 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 itrequires 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 thatmightyieldbetteror 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
goingforward/up
andoffthebottomby
goingback/down. Th