how to draw an activity diagram

Upload: ashwin-anilkumar

Post on 03-Jun-2018

259 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 How to draw an Activity Diagram

    1/18

    Drawing Activity Diagrams

    Martin Siebenhaller, Michael Kaufmann

    WSI-2006-02

    ISSN 0946-3852

    Arbeitsbereich Paralleles Rechnen - Prof. Dr. Michael KaufmannWilhelm-Schickard-Institut fr Informatik,

    Fakultt fr Informations- und Kognitionswissenschaften,Eberhard-Karls-Universitt,

    Sand 13, 72076 Tbingen, Germany

    Email: {siebenha,mk}@informatik.uni-tuebingen.de

    cWSI, 2006

  • 8/11/2019 How to draw an Activity Diagram

    2/18

    Martin Siebenhaller

    University of TbingenMichael Kaufmann

    University of Tbingen

    Activity diagrams experience an increasing importance in the de-sign and description of software systems. Unfortunately, previ-ous approaches for automatic layout support fail or are just insuf-ficient to capture the complexity of the related requirements. Wepropose a new approach tailored to the needs of activity diagramswhich combines the advantages of two fundamental layout con-cepts called Sugiyamas approach [Sugiyama et al. 1981] andtopology-shape-metrics approach [Tamassia et al. 1988], origi-nally developed for layered layouts of directed graphs and for or-thogonal layout of undirected graphs respectively.

    Keywords: Activity Diagrams, Software Visualization, GraphDrawing

    Activities and the corresponding activity diagrams belong to thebasic concepts of the Unified Modeling Language (UML) whichhas become the standard modeling language for specifying, visu-alizing and documenting software systems. Activity diagrams areused for modeling behavioral logic like business processes or work-flow. In the modern UML 2, they experienced an increasing impor-tance. While they were considered as a special case of state dia-grams in UML 1.x, they are now enriched with additional constructsthat widens the range of their applicability. This make them moresuitable for areas like economics or bio-informatics [Shegogue andZheng 2005].

    OrderProcessor

    InvoiceSend

    Invoice

    Ship

    Order

    Fill

    Order

    Make

    Payment

    accepted][order

    Receive

    Order

    Close

    Order

    [order rejected]

    RenoSeattle

    AccountingClerk

    Figure 1: An UML activity diagram taken from the UML 2.0 Su-perstructure specification (http://www.uml.org).

    While automatic layout for class diagrams received considerable at-tention by developers of corresponding software tools and designersof fundamental concepts of diagramming, activity diagrams wereconsidered either to be just a special case for tools supporting statediagrams or to be too complex to handle them by a direct applica-tion of basic layout algorithms.

    Activity diagrams require properties different from those for classdiagrams such that the concepts developed there cannot be trans-ferred, although the experiences gained help with the design. Here

    e-mail: [email protected]:[email protected]

    the emphasis lies on partitions and flow, some properties that areinfluenced by the semantics of activity diagrams. Those propertieshave to be supported by an automatic layout algorithm because itis hard, or sometimes even impossible to place all elements appro-priately by hand. Furthermore, an automatic layout algorithm withcustomizable layout options allows to include different user prefer-ences.

    The contribution of this paper is a summary of the needed require-ments and aesthetics for drawing activity diagrams, and the elabora-tion of sophisticated graph drawing algorithms for a new layout ap-proach which satisfies them. We do not introduce a completely newconcept, but we show for the first time how to combine the two lay-out concepts Sugiyama approach and topological-shape-metricsapproach, which were originally developed for layered layouts of

    directed graphs and for orthogonal layouts of undirected graphs re-spectively. We demonstrate how to extract the advantages from bothmethods and apply them successfully to the challenging problem oflayout UML activity diagrams.

    The rest of our paper is organized as follows: In Section 2 we dis-cuss the requirements and aesthetic criteria of activity diagrams.Section 3 reviews the state-of-the-art of drawing activity diagramsand Section 4 describes the basic definitions and algorithms whichprovide the basis for our new visualization approach. In Section 5we introduce our new concepts followed by a short discussion.

    In this section we examine requirements for the automatic layoutof activity diagrams. We therefore shortly introduce the notationelements. This is necessary to derive a graph theoretic concept tolayout those diagrams. We also analyze aesthetics and standards forcreating activity diagrams. The identified aesthetics and require-ments are the basis for the design of our new layout algorithm.

    In the following we give an overview of the visual notation of activ-ity diagrams and identify the resulting requirements for the layoutalgorithm. We do not focus on semantics if not necessary. For

    further details have a look at the UML superstructure specification[OMG 2004].

    Anactivityspecifies the coordination of executions of actions usinga control and data flow model. Eachactivity diagramshows exactlyone activity. An activity is modeled as a labeled graph ofactivitynodeswhich are connected by edges denoting data or control flow.It can optionally be represented by a border rectangle containing allits elements and a name shown in the upper left corner. There arethree different node types appearing in an activity - action, objectand control nodes.

    Action nodes (see Fig. 2(a)) are the basic elements of an activity.An action node may have outgoing and incoming edges denotingcontrol or data flow to or from other nodes. There are two specialkind of action nodes to handle signal events, the accept eventand

  • 8/11/2019 How to draw an Activity Diagram

    3/18

    send signalaction. Object nodesindicate an instance of a particularclassifier (see Fig. 2(c)).

    Acontrol node (see Fig. 2(b)) coordinates the flow between othernodes. If an activity is invoked, a flow starts at each initial node. Ifa flow reaches anactivity final nodethe activity terminates. In con-trast, aflow final nodeterminates only its incoming flow. Adecision

    nodehas one incoming flow and multiple outgoing edges. The flowis forwarded to only one outgoing edge. This edge is commonly de-termined by guardswhich are edge labels representing conditions.Amerge nodehas one outgoing edge and multiple incoming edges.Each flow arriving at an incoming edge is forwarded to the outgo-ing edge. Afork nodeis similar to a decision node, but it splits theincoming flow into multiple concurrent flows. A join nodeis sim-ilar to a merge node, but synchronizes multiple flows. Edges arealways connected to the long side of the fork/join node. The nodescan be placed vertically or horizontally.

    send signalaccept eventaction

    (a) action nodes

    merge/decision node join/fork nodeflow final activity finalinitial node

    (b) control nodes

    object node

    (c) object node

    note

    (d) note

    partition

    name

    2

    name3 name4partition partition

    partition

    name1

    (e) partition

    keyword

    (f) expansion region

    Figure 2: Activity diagram notation elements.

    Node elements can be connected by two different edge types, onedenoting control flow and one denoting data flow. Both edge typesare represented by an arrowed line.

    There are also notation elements for defining sets of nodes andedges in an activity. Partitions (swim-lanes) use vertical or hori-zontal boundaries to partition a diagram into logical areas, e.g. or-ganizational units in a business model. Nodes and edges are placedinside the related partition. UML 2 diagrams can also be parti-tioned as depicted in Fig. 2(e). Such a partition is a combination ofhorizontal and vertical swim-lanes. Hence, the partition structurecorresponds to a grid. Another grouping element is an expansionregion. It is a strictly nested region of an activity with explicit inputand output nodes calledexpansion nodes(see Fig. 2(f)). Each inputis a collection of values. Expansion regions can have keywords inthe upper left corner. Aninterruptible activity regionhas the samenotation as an expansion region but without expansion nodes.

    A notation element available to all UML diagrams is anote. Notescomment on some diagram elements. They are attached to the cor-responding elements by a dashed line (see Fig. 2(d)). In activitydiagrams notes are often used to show post- and preconditions ofactions.

    The visual notation leads to the following requirements:

    Nodes have different sizes (NODE_SIZE). We have to consider partitions (PARTITION). Regions could be nested and edges can start/end at a region

    (expansion input/output nodes). This corresponds to the con-cept of compound graphs (see Section 4.1) (CLUSTER).

    Handle notes that are attached to edges (NOTES). Join/fork nodes are two sided nodes(TWO_SIDED_NODES).

    Handle labels of activities, regions, nodes, edges (LABEL).

    Since activities are based on a graph theoretic concept we are able toemploy graph drawing techniques to draw activity diagrams. Thereis a wide variety of drawing algorithms taking different aestheticsand requirements into account [Di Battista et al. 1999b; Kaufmannand Wagner 2001]. There are also approaches for handling labelsand clusters. Note, that in graph theory the nodes are usually calledvertices. However, in this work we use the term nodes to be consis-tent with the UML specification.

    An aesthetics measures a graphical property of a drawing thatshould be optimized to increase readability. Unfortunately, up tonow there are neither work nor empirical studies for aesthetics ofactivity diagrams. However, since the underlying structure of ac-tivity diagrams are graphs, we will discuss aesthetics that apply toabstract graphs (graphs without special semantics) and thus to ac-tivity diagrams, too.

    An overview of aesthetic criteria applied to drawings of abstractgraphs is given in [Di Battista et al. 1999b; Coleman and Parker1996]. The most common are:

    Minimize the number of edge crossings (CROSSING). Minimize the area of the drawing (AREA). Minimize the maximum length of an edge

    (EDGE_LENGTH). Minimize the number of bends (BEND). Maximize the smallest angle between two edges incident on

    the same node (ANGLE). Minimize the deviation of an 1 : 1 aspect-ratio (AS-

    PECT_RATIO). Minimize the number of overlapping nodes and edges

    (OVERLAP). Maximize the number of orthogonal edges (edges that are

    drawn as a sequence of horizontal and vertical line segments)(ORTHOGONAL).

    Maximize the number of edges respecting flow (edges that aredrawn monotonically in a prescribed direction) (FLOW).

    Maximize symmetry (SYMMETRY).

    Note, that there are some contradicting aesthetics, e.g. FLOW andASPECT_RATIO. The drawing of a graph with a given set of aes-thetic criteria can be seen as a multi-objective optimization prob-lem. The set of applied criteria depends on the semantics of thegraph as well as on individual user preferences.

    The affect of aesthetics BEND, CROSSING, ANGLE, ORTHOG-ONAL and SYMMETRY on the readability of drawings were ana-lyzed empirically in [Purchase et al. 1997; Purchase 1997]. There,CROSSING was found out to be the most important, followed bythe less important aesthetics BEND and SYMMETRY. ORTHOG-ONAL and ANGLE had no significant effects.

    Since activity diagrams show control and data flows it seems to benatural to include aesthetics FLOW. In activity diagrams the edge

    2

  • 8/11/2019 How to draw an Activity Diagram

    4/18

    flow is usually from top to down or from left to right. OVER-LAP is also important; especially overlaps between nodes shouldbe avoided. SYMMETRY seems to be useless to activity diagramsbecause they do not have a symmetric structure.

    Although the UML specification does not explicitly prescribe howto layout diagrams, there are a lot of standards, conventions andguidelines how to do this. A comprehensive collection of thoseprinciples that have been proven in practice is given in [Ambler2005]. Their usage increases the usability and clarity of diagrams.Here we give an overview.

    The principles for general UML diagrams are:

    Minimize the number of crossings (CROSSING). Draw edges orthogonal (ORTHOGONAL). Use only horizontal labels (HORIZONTAL_LABELS). Reorganize larger diagrams into several smaller ones. This

    principle is based on the fact that it is often easier to have sev-

    eral diagrams on various levels of detail than a single complexone. Hence, complex actions are often decomposed into sub-activities. In practice there are almost no activity diagramscontaining more than 50 nodes and 80 edges, which allows usto use more complex algorithms than for larger graphs.

    The following principles were specific to activity diagrams:

    Incoming and outgoing edges enter a join (fork) node on dif-ferent sides (BIMODALITY).

    Swim-lanes (partitions) should be ordered in a logical manner,the primary swim-lane is placed leftmost. Thus, we assumethat the ordering of the partitions is given as input.

    In this section we have identified requirements and aesthet-ics for drawing activity diagrams. Notation dependent re-

    quirements are CLUSTER, PARTITION, NODE_SIZE, NOTES,TWO_SIDED_NODES and LABEL. Furthermore, we havestructure-dependent aesthetics like CROSSING, BEND, OR-THOGONAL, FLOW, AREA, EDGE_LENGTH and OVERLAP.BIMODALITY and HORIZONTAL_LABELS are additional re-quirements based on standards and conventions for creating activitydiagrams. It is important to have a flexible layout approach that al-lows the user to customize requirements.

    In this section, we review the state-of-the-art of drawing activitydiagrams. First we give an overview on related work in research

    followed by a brief evaluation of some popular commercial soft-ware products.

    Most of the recent work on layout approaches for UML diagramswas dedicated to class diagrams. Representatives of two differentapproaches are UMLKandinsky/GoVisual [Eiglsperger et al. 2004]and SugiBib [Eichelberger 2002b]. The first one is based on refine-ments of the fundamental topology-shape-metrics (TSM-) approachwhich has been developed for orthogonal layouts. The second oneuses the well known concept of Sugiyama for layered layouts. Bothapproaches will be described in Section 4. They support aestheticcriteria like FLOW, ORTHOGONAL, OVERLAP, CROSSING in

    various ways. SugiBib is also able to consider advanced proper-ties like CLUSTER but on the other hand it is rather weak for ba-sic properties like NODE_SIZE or ORTHOGONAL. None of theabove approaches is able to handle PARTITION.

    A layout approach for statecharts is given in [Castello et al. 2002a;Castello et al. 2002b]. Statecharts are extended finite state machines

    and support the repeated decomposition of states into substates.The approach is based on a combination of Sugiyamas approachwith a recursive floorplanning algorithm and an integrated label-ing method. It supports aesthetics AREA, CROSSING, OVERLAP,BEND, ASPECT_RATIO and CLUSTER. However, the clusteringis specific to state decompositions and thus not applicable to activ-ity diagrams.

    There is also some work about the visualization of process dia-grams. Process Diagrams are related to flowcharts and visualize theflow through a process or system. The layout approaches describedin [Wittenburg and Weitzman 1997] and [Six and Tollis 2002] sup-port FLOW and PARTITION. The second one is also able to sup-port ORTHOGONAL, CROSSING, BEND and OVERLAP. How-ever, both approaches are restricted to one-dimensional partitions(horizontal swim-lanes) and do not include CLUSTER.

    As we have seen there is no conceptual approach covering all re-quirements for activity diagrams. On the other side there exist quitea few commercial products that claim to support activity diagrams.In the following subsection we review some of them.

    An evaluation of layout capabilities for different UML tools regard-ing class diagrams was given in [Eichelberger 2002a]. For mosttools the contained layout algorithms did not produce satisfying re-sults. Meanwhile some of the tools provide improved layout ca-

    pabilities. In the following we review some popular UML toolswith respect to their auto layout capabilities for activity diagrams.We are particularly interested in their ability to handle requirementsFLOW, CLUSTER and PARTITION.

    EclipseUML Studio for Java 2.1.0 beta (Omondo)( )Up to know EclipseUML does only support UML 1.xnotation for activity diagrams without partitions. It does notprovide an auto layouter for those diagrams.

    MagicDraw UML 11 Enterprise Edition (NoMagic)( )

    MagicDraw fully supports UML 2 notation. It providesseveral standard auto layout approaches and edge routers(an edge router does not change node positions). Thehierarchic layouter is able to consider FLOW, PARTITIONand CLUSTER. However, when using partitions aestheticsFLOW is not always fulfilled satisfactorily (see Fig. 3(b)) andthe resulting drawings are sometimes defective. Notes arealways placed outside the corresponding partition cell/region,far away from the related element.

    Poseidon for UML 4.1 Professional (Gentleware)( )Poseidon fully supports UML 2 notation for activity diagrams.However, it does not provide an auto layouter for them.

    3

  • 8/11/2019 How to draw an Activity Diagram

    5/18

    (a) New Approach (b) MagicDraw UML 11

    (c) Visual Paradigm for UML 5.3

    Figure 3: Comparison of different layout tools (using the example of Figure 1). Only our new approach produces an adequate drawing.

    4

  • 8/11/2019 How to draw an Activity Diagram

    6/18

    Rational Software Architect V 6.0 (IBM)(

    )

    Rational supports UML 2 notation for activity diagrams but itonly allows one-dimensional partitions (vertical swim-lanes).The provided auto layouter does not consider FLOW butit is able to consider CLUSTER. However, it does notlayout elements inside a region. When using swim-lanes the

    layouter only includes elements of the leftmost swim-lane.The layout quality is very poor.

    Together Architect 2006 for Eclipse (Borland)( )Together does only support a subset of UML 2 notation.Partitions and regions are not available. Together providesseveral standard layout approaches. However, the layoutresults are poor. The layouter does not support aestheticsFLOW and often violates aesthetics OVERLAP and CROSS-ING.

    Visual Paradigm for UML 5.3 Enterprise Edition (VisualParadigm)( )

    Visual Paradigm fully supports UML 2 notation for activitydiagrams. It provides a hierarchic layout approach as well asan orthogonal edge router. The hierarchic layouter is able toconsider FLOW, CLUSTER and PARTITION but when us-ing partitions with horizontal swim-lanes the elements are notplaced correctly and the layout results are poor (see Fig. 3(c)).Furthermore, it sometimes produces unnecessary overlaps.

    The layout capability and quality of the above UML tools heavilydiffers. None of them was able to produce satisfying results. OnlyMagicDraw and Visual Paradigm incorporate partitions. However,as Figure 3 shows, both produce poor results when using partitionseven for small diagrams.

    In this section we describe the basic definitions as well as the ba-sic algorithms which provide the basis for our visualization. Ourapproach combines the layered approach of Sugiyama with a TSM-approach for orthogonal layouts.

    Agraph G= (V,E)consists of a node set Vand an edge set E

    VV. If all pairs inEare ordered, we call G directed graph, ifall pairs are unordered we call it undirected graph. A self-loopisan edge that starts and ends at the same node. If there are multipleedges between a pair of vertices, those edges are calledmultiedges.A (simple) path between node v and w is a node sequence (v=u1,u2, . . . ,uk= w), such that u1,..,uk V,(ui,ui+1) E, 1 i k1 andui=uj, 1 i = j k. It is denoted byv

    Gw. Acycle

    is a non-empty path with u1=uk. If a graph contains no cycles it iscalledacyclic. An undirected graph is calledconnectedif there is apath between every pair of nodes. A directed graph is connected ifits undirected version is connected. Atreeis an undirected, acyclicand connected graph (|E|= |V|1). ThedegreeG(v)of a nodev V is the number of edges incident tov. IfG is directed, G(v)can be divided into the out-degree+G(v) = |{w|(v,w)E}| and the

    in-degree

    G

    (v) = |{w|(w,v) E}|.

    A drawingof a graph G= (V,E) is a mapping of the node set Vto distinct points in the plane and the edge set Eto open Jordancurves. G is called planar, if it has a drawing in the plane with-out edge crossings, that is no two Jordan curves have a commonpoint. Such a drawing divides the plane into regions, called faces(see Fig. 4(a)). There is exactly one unbounded region which iscalled theouter face. Anembeddingof a graph is given by a clock-

    wise cyclic ordering of the adjacent edges around each node. Anembedding is called planar if there is a planar drawing of the graphwhich preserves this ordering.

    Thedual graph DGof a planar embedding ofG has a node vf foreach face fofGand an edge(vf,vg)for each edge ofGseparatingtwo (not necessarily distinct) faces fandg(see Fig. 4(b)). The dualgraph has always linear size and is planar, too.

    f0

    f2

    f1

    f3

    (a) planar drawing (b) dual graph

    Figure 4: Figure (a) shows a planar drawing of a graph and thecorresponding faces (f0 denotes the outer face). Figure (b) showsthe related dual graph. Its nodes are denoted by circles and theedges by solid curves.

    An upward drawing of a directed graph G = (V,ED)is a drawingofG such that all edges are represented by monotonically increas-ing curves in the vertical direction. Note, that such a drawing existsif and only ifG is acyclic. Gis called upward planarif it has anupward and a planar drawing at the same time. Note, that there aregraphs which have an upward and a planar drawing but are not up-ward planar (see Fig. 5(a)). An upward embedding of a graph isgiven by a clockwise cyclic ordering of the adjacent edges aroundeach node in which the incoming and outgoing edges form an in-terval. Such an ordering is called bimodal. An upward embeddingis planar if there is an upward planar drawing of the graph whichpreserves the corresponding ordering.

    (a) (b) (c)

    Figure 5: Example graphs. Dashed rectangles represent clusters.

    A mixed graph is a tuple G= (V,ED,EU) (V,V V,V V),whereVis the set of nodes, ED the set of directed edges and EUthe set of undirected edges. A mixed upward drawing of G is adrawing such that the edges of ED are represented by monotoni-cally increasing curves in the vertical direction. Gis called mixedupward planar if it has a mixed upward and a planar drawing atthe same time. A mixed upward embedding is planar if there isa mixed upward planar drawing of the graph which preserves thecorresponding ordering.

    5

  • 8/11/2019 How to draw an Activity Diagram

    7/18

    A compound graph GC= (G,T) consists of a graph G = (BC,EG)(called underlying graph) anda directed rooted treeT= (BC,ET)(calledinclusion tree). The node setB contains thebase nodesandthe setCthe compound nodes. Compound nodes (=clusters) con-tain base nodes or other compound nodes. T defines the contain-ment relation. The tree edgese ETare directed from the root tothe leafs. A directed pathvT w indicates that node w belongs

    to nodev. Thus, each base node is a leaf ofTand the compoundnodes are the inner nodes. The root ofTis a special compoundnode which represents the whole drawing area and thus includeseach element. An example is given in Figure 6.

    In a cluster drawing of a compound graph GC, each compound nodec Cis drawn as a simple closed region (usually as rectangle). Theregion ofc contains a base node v Bif and only if there is a pathc T v. Analogously, it contains the region of a compound nodec if and only if there is a path cT c

    . Furthermore, each edgecrosses the boundary of a region at most once. A compound graphis calledc-planarif it has a planar and a cluster drawing at the sametime. There are graphs which have a cluster drawing as well as aplanar drawing but are not c-planar (see Fig. 5(b)).

    a

    b

    l

    j

    k

    h

    i

    f

    e

    d

    c

    g

    (a)

    a b

    l

    j kh i

    fedc

    g

    (b)

    a

    c d

    b

    l

    j

    k

    h

    i

    f

    e

    g

    (c)

    Figure 6: Example for a compound graph, where compound nodes

    are drawn as rounded rectangles with dashed border. Figure (a)shows the underlying graph, Figure (b) the corresponding inclusiontree and Figure (c) the resulting cluster drawing.

    Agrid partition Pm,n subdivides the drawing area into m columnsand n rows which are separated bym+1 vertical and n+1 horizonallines, respectively (see Fig. 7(a)). Note, that in our approach thesize of the rows (columns) is non-uniform. A cell of the grid iscalledpartition cell. pi,jdenotes the partition cell located in the i-th column and j-th row of the grid (p1,1is located in the upper leftcorner). Thei-th grid column contains all partition cells pi,j with1 j nand the j-th grid row contains all partition cells p i,jwith1 im. For a grid partition Pm,nthe correspondinggrid partitiongraph PGm,nis constructed by placing nodes on intersection points ofhorizontal and vertical grid lines (see Fig. 7(b)).

    2,1p1,1

    p3,1

    p1,2

    p2,2

    p3,2

    p

    (a) (b)

    Figure 7: Example of a grid partition P3,2(a) and the corresponding

    grid partition graphPG3,2(b).

    Let G = (V,E) denote a graph, Pm,n a grid partition and p : VNN a function assigning each node v Vto a partition cell.

    Definition 1 In a partitioned drawing of G each node v V isdrawn inside p(v). G is calledp-planar if it has a planar and apartitioned drawing at the same time.

    Theorem 1 A graph G= (V,E)is p-planar if and only if it is pla-nar.

    Proof: A p-planar graph is planar by definition. Let us assume thateach nodev Vis assigned to an arbitrarily distinct location insideits partition cell p(v). In [Pach and Wenger 1998] Pach and Wengershow that every planar graph admits a planar embedding in whicheach vertex is mapped to an arbitrarily prescribed distinct location.This implies that each planar graph is p-planar, too.

    Definition 2 A mixed compound graph GChas apartitioned mixedupward cluster drawing if it has a cluster, a mixed upward and apartitioned drawing at the same time. Furthermore, GC is calledmixed upward pc-planar, if it has a planar and a partitioned mixedupward cluster drawing at the same time.

    There are graphs which are upward planar and c-planar but not up-ward c-planar (see Fig. 5(c)). In our approach cluster regions are

    not allowed to cross partition cells. Thus each compound node canbe assigned uniquely to a partition cell. Under this assumption eachgraph has a partitioned cluster drawing. A graph has a partitionedupward drawing if it is acyclic and for each e= (v,w) ED withp(v) = p i,jand p(w) = pk,lholds j l.

    The most common approach for producing layered drawings fordirected graphs is the abstract framework developed by Sugiyamaet al [Sugiyama et al. 1981]. It indicates a common direction ofthe edges by producing layered layouts. Sugiyamas frameworkconsists of four phases:

    1. Cycle Removal: In the cycle removal phase, the directed in-put graphG = (V,E)is made acyclic by reversing appropriateedges (see Fig. 8(b)).

    2. Layer Assignment: During the layer assignment phase, thenodes are assigned to horizontal layers L1,..,Lh such that foreach edgee = (v,w) Ewithv Liand w Lj holdsi < j.After this assignment, edges between nodes of non-adjacentlayers (long edges) are replaced by chains of dummy nodesand edges between the corresponding adjacent layers. Thisprocess is called normalizationand the result is the normal-ized graphNG= (VN,EN)(see Fig. 8(c)).

    3. Crossing Reduction: In the crossing reduction phase, an or-dering of the nodes within a layer is computed such that thenumber of edge crossings is reduced (see Fig. 8(d)). The re-sult is a directed acyclic compaction graph CG= (VN,{(a,b) :

    6

  • 8/11/2019 How to draw an Activity Diagram

    8/18

  • 8/11/2019 How to draw an Activity Diagram

    9/18

    a b c

    ed f

    (a) input graph

    b

    c

    a

    f

    e

    d

    (b) planarization

    b

    c

    a

    d

    f

    e

    (c) orthogonalization

    b

    c

    a

    d

    f

    e

    X

    X

    X

    X

    XX

    XX

    X

    X

    X

    X XX X XX

    X

    X

    X

    X

    X

    X

    X

    (d) compaction

    Figure 9: The three phases of the TSM-approach. The white dummy node represents a crossing.

    approaches try to minimize the number of edge crossings dur-ing this phase.

    2. Orthogonalization: The orthogonalization phase fixes theshapes of the edges in a drawing. It therefore determinesedge bends and angles between adjacent edges. In orthogo-nal drawings each edge is drawn as a sequence of horizontal

    and vertical line segments. Thus, each angle is a multiple of90 (see Fig. 9(c)). Orthogonalization algorithms usually tryto minimize the number of edge bends.

    3. Compaction: The compaction phase determines the final co-ordinates of graph elements such that nodes and bends areplaced on grid points. Finally, the inserted dummy nodes areremoved (see Fig. 9(d)). During this phase most approachestry to minimize the area or the total edge length of the draw-ing.

    In [Tamassia 1987] Tamassia introduced a network flow based ap-proach which computes a bend-minimal orthogonal point drawingfor plane 4-graphs. We use the Kandinsky model [Fmeier andKaufmann 1996] for the orthogonalization which is an extensionof Tamassias algorithm and copes with general planar graphs and

    nodes of prescribed size [Di Battista et al. 1999a]. Even though thecomplexity for finding a bend-minimal solution in the Kandinskymodel is not known, there is an effective network flow formula-tion which has at most twice the number of bends of the optimalsolution [Eiglsperger 2003]. Furthermore there is a heuristic net-work solver that produces satisfying results in practice [Eiglsperger2003; Wiese et al. 2002] in timeO(n2 log n). There are several ex-tensions of the Kandinsky model that are applicable to our purpose,e.g. the usage of prescribed angles and bends [Brandes et al. 2002]as well as the usage of prescribed edge shapes [Eiglsperger et al.2004; Eiglsperger 2003].

    Both, the layered approach and the TSM-approach, have their ad-vantages. The layered approach is especially suited to satisfy theFLOW criteria. It is highly adaptable and there are sophisticatedapproaches to handle requirement CLUSTER. The TSM-approachis particularly suited to satisfy aesthetics ORTHOGONAL. Sinceedges are paths of horizontal/vertical segments it also optimizesaesthetics ANGLE. Furthermore, NODE_SIZE can be realized ina more natural way than for layered approaches. There are sophis-ticated methods to produce mixed upward drawings which yieldless crossings than Sugiyama-based approaches [Eiglsperger 2003].Both are able to avoid overlaps and thus optimize aesthetics OVER-LAP. Our idea is to combine both concepts to take advantage ofsynergies. More precisely, we take Sugiyamas approach to createa planarization and then continue with the TSM-approach.

    In this section we present our new approach for the auto-matic layout of activity diagrams. Besides the common aes-thetics ORTHOGONAL, OVERLAP, CROSSING, BEND, AREA,

    FLOW it is also able to consider requirements like CLUS-TER, PARTITION, BIMODALITY, NODE_SIZE, LABELINGand TWO_SIDED_NODES. To our knowledge there is no exist-ing algorithm that is able to handle such a complex combination ofrequirements.

    First we introduce the interface to our visualization approach. Theinput of the layout algorithm is:

    a mixed compound graph GC= (G,T), G= (V,EG), T =(V,ET), V= BC,EG= EDEU a set of labelsL, a function s : B L NN denoting the size of the nodes

    and labels in the drawing, a function py : V N assigning each nodev Vthe row in-

    dex of the corresponding partition cell, a function px : V N assigning each nodev Vthe column

    index of the corresponding partition cell.

    To each base node one of the following node types is assigned:initial node, final node, expansion node, object node, activity node,fork/join node, decision/merge node or note.

    In a transformation step the activity diagram graph is transformed

    into a suitable input for the layout algorithm. Due to semantic rea-sons, the input graph does never contain self-loops or multiedges.

    The algorithm can be customized to fit individual user preferencesand different views on a diagram. The user can, for example, decideif PARTITION should be applied, if CLUSTER is more importantthan aesthetics FLOW or if FLOW should not be considered at all.

    Note, that in activity diagrams the edges of ED are drawn down-ward instead of upward. All edges ofEGare directed except edgesincident to notes. However, only directed edges that are added toED are drawn downward. We propose to add all edges to ED thatare not connected to a node of type initial node, final node or note.It is not always possible to fully satisfy aesthetics FLOW, but ouralgorithm guarantees BIMODALITY for each base node.

    8

  • 8/11/2019 How to draw an Activity Diagram

    10/18

    We continue with an overview of the single steps of our algorithm:

    1. Preprocessing(a) Recall, that notes are attached to edges by dashed lines.

    We use a dummy node as attachment point (see Fig-

    ure 14(c)) (NOTES). Notes attached to node elementsare handled like usual nodes.

    (b) We replace each compound nodec Cby two nodesct and cb representing the top and bottom border ofthe corresponding cluster region. All incoming edges(v,c) EG, v Vare connected to c

    t and all outgoingedges(c,v) EG,v V toc

    b.(c) If the subgraph induced by the nodes ofB is not con-

    nected, we add additional edges between its connectedcomponents. We therefore choose an action node ofeach component and then connect those nodes by aspanning tree. Due to semantical reasons each compo-nent has at least one action node.

    (d) For each edge e = (u,v) ED we check if py(u) py(v). If not, e cannot be drawn downward and thusis removed fromEDand inserted into EU.

    2. Planarizationwill be described in Section 5.3.

    3. Orthogonalizationwill be described in Section 5.4.

    4. Compaction(a) First, labels are inserted into the orthogonalized graph

    as described in Section 5.5.(b) The compaction phase uses the fast constructive com-

    paction algorithm described in [Eiglsperger and Kauf-mann 2002] that is able to handle nodes of prescribedsize (NODE_SIZE). An experimental study comparingdifferent orthogonal compaction algorithms [Klau et al.2001] shows that the results of different constructivecompaction heuristics are almost the same when us-ing a flow-based post-processing step. Thus, we usethe flow-based visibility post-processing strategy de-scribed in [Eiglsperger 2003] to further optimize aes-thetics AREA and EDGE_LENGTH. During the com-paction all dummy nodes, except those representing la-bels, get unit size.

    5. Postprocessing(a) All dummy nodes and edges inserted during the previ-

    ous steps are removed.(b) Rectangles denoting cluster regions as well as the grid

    partition are inserted into the drawing. Finally, the rect-angle denoting the border of the activity is drawn andthe activitys label is placed (optionally).

    Our planarization strategy combines the layered approach ofSugiyama with a rerouting strategy known from the TSM-approach.This section is partly based on our previous work, see [Siebenhallerand Kaufmann 2006; Blochinger et al. 2006]. We start with describ-ing the specific modifications of the different phases of Sugiyamasapproach with respect to the identified requirements and aesthetics.

    Common layer assignment approaches are designed to realize aes-thetics FLOW. In our application the layering has to deal with re-

    c b

    a

    b

    lj kh i fe

    dc

    g

    t

    t

    t t

    d bbb

    ab

    r t

    r b

    Figure 10: Nesting graph for the compound graph of Figure 6.

    quirements CLUSTER and PARTITION, too.

    LetL(v)denote the index of the layer of a node v(L(v) = i vLi,1 i h). For a compound nodec Cthe layering has to meetthe following condition: For each base node w B with cT wisL(ct)< L(w)< L(cb) and for each compound node d Cwithc T dis L(c

    t)

  • 8/11/2019 How to draw an Activity Diagram

    11/18

    solve a weighted feedback arc (=edge) set problem, which consistsof finding a minimum weight edge set A {Epn ED}, such that(V,{Epn ED} \A) is acyclic. This problem is NP-hard [Gareyand Johnson 1979] but several heuristics were proposed in prac-tice [Flood 1990]. We use the heuristics of [Demetrescu and Finoc-chi 2003] that runs in timeO(|V||EG|). Note, that the edge weightsguarantee thatA EDand thusAEpn= /0 which is necessary for

    a proper layering. All edges ofED \Aare inserted into Gpn. Theedges ofAare moved fromEDtoEU, because they cannot be drawndownward.

    The edges ofEUare not yet inserted into Gpn. Since those edgesneed not to be directed downward the only restriction on the layer-ing is thatL(u) =L(v)for each edgee = (u,v)EU. Therefore, wecalculate a topological orderof the nodes ofGpnand temporarilyorient all edgese EUfrom the lower to the higher node index in. This guarantees thatGpn remains acyclic after inserting thoseedges. The layer assignment can be done with a common layer-ing approach, e.g. a longest path layering or the network-simplexlayering [Gansner et al. 1993].

    After the layer assignment, all edges e / EG are removed. We

    normalize the graph by replacing long edges by chains of dummynodes and edges (see Section 4.2). Let pxj, 1 j pmax

    x + 1 de-note the vertical grid line which separates grid column j1 and j.

    For each pxjwe additionally insert a dummy nodeupxji on each layer

    Li, 1 i h. Furthermore, for each compound nodec Cwe in-

    sert two dummy nodesucl

    i anducr

    i on each layerL(ct) i L(cb)

    representing the left/right border of the cluster region. The num-ber of dummy nodes and edges inserted during normalization isO(|V||EG|).

    Unlike traditional crossing reduction, we also have to consider re-quirements CLUSTER and PARTITION here.

    Our crossing reduction is based on the method described in [Forster2002]. First a layer hierarchy tree TLi is computed for each layerLi, 1 i h. TLi is the subgraph ofTthat is induced by all nodesrelevant for layerLi, that are all base nodesv BwithL(v) =iandall compound nodesc CwithL(ct) i L(cb).

    Regarding clusters, there are two new restrictions during a one-sided two-layer crossing minimization step of layerLi1and Li:

    All (compound and base) nodes of layer Li belonging to thesame compound node have to be consecutive.

    Letc,d Cdenote two compound nodes with L(ct),L(dt) i1 andi L(cb),L(db). Then the relative position ofcanddmust be the same on both layers.

    In [Forster 2002] the following theorem has been shown:

    Theorem 2 An order of the base nodes has a minimal number ofcrossings if and only if the corresponding layer hierarchy tree hasa minimal number of crossings at each node.

    Thus, during a one-sided two-layer crossing minimization step thenumber of crossings can be minimized by independently computingan order of the children for each compound node without loosingquality. The corresponding algorithm is based on a conventionalalgorithm for weighted one-sided two-layer crossing minimization.

    The preservation of the relative position of two clusters is guar-anteed by using a constraint crossing minimization [Forster 2005]

    where the order of some node pairs is already given. Thus, the rela-tive ordering of two compound nodes can be preserved by insertinga constraint between them.

    When the layer hierarchy trees have bounded degree the crossingreduction of a compound graphGCruns in timeO(|V||EG|) [Forster2002]. SinceGCcan includeO(|V||EG|)dummy nodes and edges,

    the overall running time of the crossing reduction is O(|V|2|EG|2).We use the following strategy to include partitions: During a one-sided two-layer crossing minimization step, we first sort all nodesof the non-fixed layer according to their px(v)values in ascendingorder. Now, we simply apply the above algorithm to all nodes withthe same pxvalue (nodes in the same grid column) independently.Recall, that cluster regions do not intersect partition cells. Regard-ing the quality of the separate handling of grid columns we can statethe following theorem:

    Theorem 3 The order of the base and compound nodes can be cal-culated independently for each column of the grid partition withoutloosing quality.

    Proof:Regarding grid columns as clusters with fixed positions, we

    can simply apply Theorem 2.

    Since compound nodes as well as columns of the grid partition areconsidered independently, the placement of the border nodes in-serted during normalization is simple. When we process a com-

    pound nodec Cin layer Li, we simply restrictucl

    i to be the left-most node and uc

    r

    i to be the rightmost node. When we process thej-th grid column in layer Li, the resulting node sequence is placed

    betweenupxji andu

    pxj+1i .

    Note, that our crossing reduction algorithm does not depend on theone-sided two-layer crossing minimization strategy. An optimalstrategy would imply that our modified two-layer crossing mini-mization is optimal, too. However, this does not imply global op-timality because the layer-by-layer sweep may introduce unneces-sary bends. The overall running time of our crossing reduction isO(|V|2|EG|

    2).

    Let CGdenote the (Sugiyama based) compaction graph constructedas described in Section 4.2. Each cluster should be representedby an enclosing rectangle. Therefore we have to vertically align

    the left (right) border nodes ucl

    i (ucr

    i ), L(ct) i L(cb) for each

    compound nodec Cas well as the nodes upxji , 1 i hfor each

    pxj, 1 j pmax

    x + 1. The alignment is realized by simply mappingall nodes that should be aligned to the same node ofCG. Due to the

    modified crossing minimization this never introduces cycles in CG.We useCG to perform the horizontal coordinate assignment withthe algorithm proposed by Brandes and Kpf [Brandes and Kpf2002]. It produces pleasing results and runs in linear time. The edgestraightening reduces the input size of the following planarizationstep which is based on a sweep-line algorithm. Finally, all dummynodes inserted during normalization are removed.

    If the subgraphGDinduced by the edges ofEDis not yet connected,we connect it by adding additional edges ofEU toED. This is nec-essary for a common orientation of those edges. Therefore, we cal-culate a minimum weight spanning tree in which edges ofEDhavelower weight. The edges of the spanning tree are calledskeletonedges. The additional edges of added to EDnever introduce cyclesinGD(otherwise, the spanning tree can not be minimum).

    10

  • 8/11/2019 How to draw an Activity Diagram

    12/18

    Note, that after the horizontal coordinate assignment we have adrawing that already satisfies important aesthetics and requirementslike FLOW, CLUSTER and PARTITION. However, when we con-tinue and take the resulting drawing as input for the TSM-approach,we can also include NODE_SIZE, LABEL, ORTHOGONAL, BI-MODALITY and ANGLE in a natural way. In the TSM-approachnodes are not placed on fixed layers which additionally improves

    aesthetics AREA and EDGE_LENGTH. Aesthetics CROSSINGcan be further minimized by using a rerouting step for edgese EU(see Section 5.3.5). Furthermore, if CLUSTER is more importantthan FLOW, the rerouting guarantees a cluster drawing.

    In this step we create a planar embedding of the drawing producedin the above steps. We materialize compound nodes and the gridpartition in the following way: For each compound nodec C, we

    know the coordinates ct, cb, ucl

    i

    , ucr

    i

    of the top, bottom, left andright border. The cluster region ofc is represented by placing aboundary rectangle on this coordinates. The boundary rectangle

    consists of four nodes with coordinates (ucl

    i ,ct),(uc

    l

    i ,cb), (uc

    r

    i ,ct)

    and(ucr

    i ,cb)respectively connected by two horizontal and two ver-

    tical edges. Note, that input and output nodes of expansion regionssplit the corresponding horizontal edges. Similar, we insert the grid

    partition graph into the drawing using the coordinates upxji (p

    yi ) for

    the vertical (horizontal) grid lines. In both cases, all vertical edgespoint downward and all horizontal edges to the right. The verticaledges are added to ED.

    To create a planar embedding, we have to replace crossings bynodes and give the cyclic order of the edges around each node. Werealize this in the following way: First we detect crossings with asweep-line algorithm. This can be done in timeO(|S| log |S|+x)whereSdenotes the set of segments and xthe number of crossings.The number of segments |S|is O(|V||EG|). For each crossing, westore its coordinates and the two participating edges. A crossing isrealized by splitting the corresponding edges with a dummy node.For an edge e = (u,v)let xe1,..,x

    ek

    denote the ordered sequence ofcrossings as they appear when walking along the edge from u to v.If we splitein this order, we always know the next segment to split(thei-th crossing of(u,v)splits segment(xei1,v)). If the crossingsare processed arbitrarily, the determination of the segment to splitdemands a more complex data structure.

    Note, that in the drawing of the graph, all edges are strictly mono-tone except the horizontal edges denoting the top/bottom border

    of cluster regions or the horizontal grid lines. Thus, we sort thecrossings according to their y-coordinate. Crossings with the samey-value are additionally sorted according to theirx-value. Hence,horizontal edges are processed in the ordered crossing sequence,too.

    A problem arising during this step are multi-crossings which arepoints where more than two edges cross. They are allowedin Sugiyamas approach but not in the TSM-approach. Multi-crossings are detected by the sweep-line algorithm and then re-placed as shown in Fig. 11(a).

    After inserting the dummy nodes which represent crossings, thecyclic order of the edges around a node can easily be determinedby means of the positions of its adjacent nodes (see Fig. 11(b)).

    L i

    L i+1

    1 2 3

    L i

    L i+1

    (a) multi-crossings

    L i

    L i-1

    L i+1

    1 2 3

    1 2 3

    v

    (b) cyclic order

    Figure 11: Planarization problems.

    The result of the above step is a mixed upward p-planar embeddingofGC. Next, we perform a rerouting step based on shortest paths

    computations in the dual graph [Di Battista et al. 1999b]. Note,that we always reroute a complete edge and not just segments. Theedges ofEUneed not be drawn downward but they are also directed(except edges adjacent to notes) and thus have to be considered tosatisfy BIMODALITY. LetER= {e|e= (u,v) EG,L(u)>L(v)}denote the set of edges reversed during the layering. Since the pla-narization is based on a layered drawing, the subgraph induced byedges ofE\ER is upward planar (after inserting crossing nodes)and thus the edge ordering around the nodes is bimodal. To guaran-tee BIMODALITY for all base nodes, we have to reroute all edgesofER. LetExdenote the set of edges that crosses a region boundarytwice. To get a cluster drawing we have to reroute those edges, too.Since the following rerouting approach cannot guarantee that edgesare inserted upward planar, we only reroute edges e ExEDif re-quirement CLUSTER is more important than FLOW. We can also

    improve aesthetics CROSSING by rerouting all edges ofEU andcheck if there is a route with fewer crossings. If we have to reroutea skeleton edge, we create a clone of it and reroute the clone. This isnecessary because the skeleton edges have to be inserted downwardand thus are not allowed to be rerouted. The copy representing theskeleton edge is removed after orthogonalization.

    Summarizing, the special requirements for the rerouting are the fol-lowing: An edge route have to guarantee that

    the edge crosses a region boundary at most once (CLUSTER), the edge is inserted bimodal (BIMODALITY), the edge does not leave the outer border of the grid partition.

    A modification of the dual graph that guarantees the first point isdescribed in [Di Battista et al. 2002]. First a common dual graphDG of GC is computed. Each node of DG is enclosed by a cer-tain set of boundary rectangles of clusters (see Fig. 12). Letc de-note the innermost cluster that encloses a node uf ofDG. Theneach node on the pathrT cenclosesuf, too (ris the root ofT).When we route an edge(v,w)we first calculate the undirected pathvT w= v,c1,..,ck,w. Each edge (uf,ug) ofDG is handled asfollows: Letcidenote the innermost cluster that enclosesuf andcjthe innermost cluster that encloses ug. Ifc i or cj is not containedin{c1,.., ck},(uf,ug) is removed temporarily. Otherwise, ifi < jwe orient(uf,ug)fromuf toug(edge can only be passed from uftoug) and ifi> jwe orient it from ugto uf. Ifi= j, then(uf,ug)is bidirectional. Now, we compute a directed shortest path betweenthe set of face nodes incident to vand the set of face nodes inci-dent to w. Edge (v,w) is inserted by following the shortest pathand replacing crossings with dummy nodes. The old route of the

    11

  • 8/11/2019 How to draw an Activity Diagram

    13/18

    edge is discarded. After each step, the dual graph has to be updatedand the temporarily removed and oriented edges are restored. Therunning time of this step is O(|EG| x + |EG|

    2 (|C|+ |P|)), wherexdenotes the number of crossings and|P| = pmaxy p

    maxx the number

    of partition cells.

    k

    e

    Figure 12: The modified dual graph for the example shown in Fig. 6when routing edge (k,e). Edges without arrows are bidirectional.The embedding of the underlying graph is shown in the background(gray nodes and dashed edges).

    To realize BIMODALITY we restrict the shortest path to start (end)only at face nodes incident tov(w) that allow a bimodal edge inser-tion.

    The third point has only to be considered, if we use partitions. If so,all nodes and edges lie inside the grid partition. The outer borderof the grid partition is a closed region. Thus, we simply remove the

    node representing the outer face from the dual graph.

    If FLOW is more important than CLUSTER, the result of thererouting is a mixed upward p-planar embedding. Otherwise, theresult is a mixed upward pc-planar embedding. In both cases thebase nodes are bimodal.

    The orthogonalization phase calculates the edge bends and the an-gles between adjacent edges. Besides aesthetics BEND, ORTHOG-ONAL and ANGLE, it has to observe FLOW, CLUSTER, BI-MODALITY, PARTITION and TWO_SIDED_NODES. Its input

    is the mixed upward p(c)-planar embedding calculated in the abovestep where all dummy nodes representing crossings are marked ac-cordingly. The whole phase is divided into three steps:

    1. Let GDdenote the subgraph induced by the downward edgese ED. In the first step, we assign a fixed downward shape toeach edge ofGD. Therefore, we calculate a tail- and a head-shape for each edge segment. The tail-shape (head-shape) de-pends on the type of the corresponding source (target) node.The algorithm iteratively chooses a node ofGD and assignsthe head-shape to the incoming edges and the tail-shape to theoutgoing edges. The different shapes are shown in Fig. 13.Note, that if one of the edge segments adjacent to a cross-ing node (see Fig. 13(c)) represents a vertical segment of aboundary rectangle or the grid partition graph it is chosen tobe the straight segment. The final shape of an edge segment

    is constructed by concatenating the corresponding tail- andhead-shape. In [Eiglsperger et al. 2004] we successfully ap-plied a similar strategy and showed that there is always a validdrawing in which the edge shapes correspond to the calculatedshape.

    2. In the second step we consider all edges. To satisfy BI-MODALITY and TWO_SIDED_NODES we put restrictions

    on the angles between specific edges. Angles between pairsof consecutive incoming and outgoing edges around nodesare restricted to be at least 90 (see Fig. 14(a)) (BIMODAL-ITY). For fork and join nodes those angles are fixed to 180

    as shown in Fig. 14(b) (TWO_SIDED_NODES). The orienta-tion of fork/join nodes is determined after orthogonalization.If edges are connected horizontally (vertically) the fork/joinis drawn vertically (horizontally). Note, that if there is at leastone edgee EDadjacent to a fork/join node it can always bedrawn horizontally. The angles around a dummy node causedby an edge note (see Section 5.2, step 1a) are fixed to the val-ues shown in Fig. 14(c) and the angles of input/output nodesof expansion regions to the values shown in Fig. 14(d). Fur-thermore, Fig. 14(e) shows the angles around nodes of the gridpartition graph. The angles around nodes of a boundary rect-

    angle correspond to that of a grid partition graphPG1,1. Note,that the angle assignment is consistent with the fixed shapescalculated in the first step. This is necessary because therecould be both edge types on a node.

    3. In the third step, we calculate a shape for each edge ofEU.The fixed shapes and angles assigned in the previous stepsare not allowed to change. Furthermore, all edge segmentsof a boundary rectangle or the grid partition graph are not al-lowed to bend. Therefore, we assign high bend costs to them.We transform fixed shapes into fixed angles and bends. Theshape calculation of the edges of EU is done with the net-work flow approach described in [Fmeier and Kaufmann1996] applying the modifications of [Brandes et al. 2002;Eiglsperger 2003] that guarantees the conservation of pre-scribed angles and bends. The algorithm has running timeO((|V|+x)2 log(|V|+x)), where x denotes the number ofcrossings.

    (a) decision nodes (b) merge nodes

    (c) crossing nodes (d) other nodes

    Figure 13: The different shapes of downward edges.

    12

  • 8/11/2019 How to draw an Activity Diagram

    14/18

    o>=90

    o>= 90

    (a) common node

    o180

    o 180

    (b) fork/join node

    note o

    90o

    90o

    180

    (c) note dummy

    o

    90o

    90o

    90o

    90

    (d) input/output nodes

    90o

    90o

    90o

    180o

    180o

    90o

    270o

    90o

    90o

    90o

    90o

    90o

    90o

    90o

    90o

    90o

    90o

    180o

    90o

    (e) grid partition graph

    Figure 14: The different angles.

    Labels can be placed at nodes, edges, clusters, (grid) partitions andactivities (LABEL). Node labels are placed inside a node and thusdo not need a special handling. Activity labels are handled duringa postprocessing step.

    Edge labels are placed as follows: After orthogonalization, edgesare paths of horizontal and vertical segments. For each labeled edgeewe choose one of its middle segments and split it into two partsby inserting a dummy node. The dummy node represents the labelleofe and thus has size s(le). We always place labels horizontallyas shown in Fig.15 (HORIZONTAL_LABELS). After compactionthe dummy nodes are removed and replaced by the corresponding

    label. If there are edge labels with preferred placement at the sourceor target node, they are placed after the final layout by an efficientmap labeling algorithm [Wagner and Wolff 1998].

    Analogously, for labels of clusters and columns of the grid partitionwe split the edge representing the top side of the enclosing rectan-gle (see Fig. 15(a)). For labels of the grid rows we split the edgerepresenting the left border (see Fig. 15(b)).

    First we discuss the time complexity of our new approach. Theplanarization step is dominated by the running time of the cross-

    label

    label

    (a)

    label label

    (b)

    Figure 15: Placement of labels on a horizontal/vertical edge seg-ment.

    ing reduction with O(|V|2|EG|2) and the rerouting of edges with

    O(|EG| x + |EG|2 (|C|+ |P|)). The orthogonalization step takes

    timeO((|V|+x)2 log(|V|+x))and the compaction step includingthe flow-based post-processing has quadratic running time. Graphsrepresenting activity diagrams are always sparse, thus we can as-sume that|EG|and x are linear in|V|. Furthermore, the number ofclusters |C| and partition cells |P| isO(|V|). Under this assumptionthe overall running time isO(|V|4).

    In our complexity analysis we assume that the number of dummynodes and edges inserted during normalization is O(|V||EG|). Wecan further improve the time complexity by using the efficient im-plementation of Sugiyamas algorithm described in [Eiglspergeret al. 2005]. It avoids introducing dummy vertices for each layerthat an edge spans and reduces the number of dummy nodes andedges toO(|V|+ |EG|)without loosing quality. Thus, the time com-plexity of the crossing minimization is reduced to O(|EG|

    2)whichresults in a new overall running time ofO(|V|3). We used a com-mon Sugiyama algorithm in this work because it allows an easierdescription of the crossing minimization and horizontal coordinateassignment phase. However, the implementation of our approachuses the fast variant.

    For the implementation we used Java 1.5 and the yFiles library

    [Wiese et al. 2002]. Some results can be seen in the appendix.For diagrams with about 50 node and 80 edge elements we typi-cally need a runtime of less than 3 seconds on a 3 GHz Pentium IVSystem with 1 GB RAM.

    In this work we identified requirements and aesthetics for the lay-out of activity diagrams. We presented a new automatic layout ap-proach for activity diagrams which combines Sugiyamas algorithmwith the topology-shape-metrics approach to take advantage of syn-ergies. Our approach satisfies a complex set of different aestheticsand requirements like PARTITION, CLUSTER, FLOW, CROSS-ING, ORTHOGONAL, BIMODALITY, TWO_SIDED_NODES,OVERLAP and AREA which makes it also applicable to otherkinds of diagrams, e.g. class or process diagrams (see Fig. 18).

    Future work might comprise an interactive version of this approach

    where the user can continuously change the diagram by adding orremoving elements. When we use our current approach to calculatea new drawing of an updated diagram, this drawing can be signif-icantly different from the previous one even for small updates ofthe diagram structure. The main goal of an interactive approach isthe preservation of the users mental map [Eades et al. 1991] of thediagram. Here, the concepts of sketch-driven layout developed in[Brandes et al. 2002] fit into this framework. However, the conceptshave to be extended to satisfy the complex requirements of activitydiagrams.

    13

  • 8/11/2019 How to draw an Activity Diagram

    15/18

    AMBLER, S. W. 2005. The Elements of UML 2.0 Style. CambridgeUniversity Press.

    BERTOLAZZI, P., BATTISTA, G. D., AND DIDIMO, W. 2000.Computing orthogonal drawings with the minimum number ofbends. IEEE Transactions on Computers 49, 8, 826840.

    BLOCHINGER, W., KAUFMANN, M., AN D SIEBENHALLER, M.2006. Visualization aided performance tuning of irregular task-parallel computations. Information Visualization 5, 2, 8194.

    BRANDES, U., AND K PF, B. 2002. Fast and simple horizontalcoordinate assignment. InProceedings of the 9th Symposium onGraph Drawing (GD 01), Springer, vol. 2265 ofLNCS, 3144.

    BRANDES, U., EIGLSPERGER, M., KAUFMANN, M., A ND WAG-NER , D. 2002. Sketch-driven orthogonal graph drawing. In Pro-ceedings of the 10th International Symposium on Graph Draw-ing (GD02), Springer, vol. 2528 ofLNCS, 112.

    CASTELLO, R., MIL I, R., AN DT OLLIS, I. G. 2002. Automatic

    layout of statecharts. Software Practice and Experience 32, 1,2555.

    CASTELLO, R., MIL I, R., A NDTOLLIS, I. G. 2002. A frameworkfor the static and interactive visualization of statecharts. Journalof Graph Algorithms and Applications 6, 3, 313351.

    COLEMAN, M. K., AND PARKER, D. S. 1996. Aesthetics-basedgraph layout for human consumption. Software Practice andExperience 26, 12, 14151438.

    DEMETRESCU, C., AND FINOCCHI, I. 2003. Combinatorial al-gorithms for feedback problems in directed graphs. InformationProcessing Letters 86, 3, 129136.

    DI BATTISTA, G., DIDIMO, W., PATRIGNANI, M., AND PIZZO-

    NIA, M. 1999. Orthogonal and quasi-upward drawings with ver-tices of prescribed size. InProceedings of the 7th InternationalSymposium on Graph Drawing (GD99), Springer, vol. 1731 ofLNCS, 297310.

    DI BATTISTA, G . , EADES, P. , TAMASSIA, R., AND TOLLIS,I. G. 1999. Graph Drawing: Algorithms for the Visualization ofGraphs. Prentice Hall.

    DIBATTISTA, G., DIDIMO, W., AND M ARCANDALLI , A. 2002.Planarization of clustered graphs (extended abstract). In Pro-ceedings of the 9th Symposium on Graph Drawing (GD 01) ,Springer, vol. 2265 ofLNCS, 6074.

    DIDIMO, W.,AN DLIOTTA, G. 1998. Computing orthogonal draw-ings in a variable embedding setting. InProceedings of the 9th

    Annual International Symposium on Algorithms and Computa-tion (ISAAC98), vol. 1533 ofLNCS, 7988.

    EADES, P., AN DWORMALD, N. C. 1994. Edge crossings in draw-ings of bipartite graphs. Algorithmica 11, 379403.

    EADES, P., LAI , W., MISUE, K., A ND SUGIYAMA, K. 1991. Pre-serving the mental map of a diagram. In Proceedings of Compu-graphics 91, 2433.

    EICHELBERGER, H. 2002. Evaluation-report on the layout fa-cilities of UML tools. Tech. Rep. 298, Institut fr Informatik,Wrzburg University, July.

    EICHELBERGER, H. 2002. SugiBib. InProceedings of the 9thInternational Symposium on Graph Drawing (GD01), Springer,vol. 2265 ofLNCS, 467468.

    EIGLSPERGER, M., A NDKAUFMANN, M. 2002. Fast compactionfor orthogonal drawings with vertices of prescribed size. In Pro-ceedings of the 9th International Symposium on Graph Drawing(GD01), Springer, vol. 2265 ofLNCS, 124138.

    EIGLSPERGER, M., GUTWENGER, C., KAUFMANN, M., KUPKE,J., JNGER, M., LEIPERT, S., KLEIN, K., MUTZEL, P., AND

    SIEBENHALLER, M. 2004. Automatic layout of uml class dia-grams in orthogonal style. Information Visualization 3, 3, 189208.

    EIGLSPERGER, M., SIEBENHALLER, M., AND KAUFMANN, M.2005. An efficient implementation of sugiyamas algorithm forlayered graph drawing. InProceedings of the 12th Symposiumon Graph Drawing (GD04), Springer, vol. 3383 ofLNCS, 155166.

    EIGLSPERGER, M. 2003. Automatic Layout of UML Class Dia-grams: A Topology-Shape-Metrics Approach. PhD thesis, Uni-versitt Tbingen.

    FLOOD, M. M. 1990. Exact and heuristic algorithms for theweighted feedback arc set problem: A special case of the skew-

    symmetric quadratic assignment problem. Networks 20, 123.FORSTER, M. 2002. Applying crossing reduction strategies to lay-

    ered compound graphs. In Proceedings of the 10th Symposiumon Graph Drawing (GD02), Springer, vol. 2528 ofLNCS, 276284.

    FORSTER, M . 2005. A fast and simple heuristic for constrainedtwo-level crossing reduction. In Proceedings of the 9th Sympo-sium on Graph Drawing (GD04), Springer, vol. 3383 ofLNCS,206216.

    FSSMEIER , U., AND K AUFMANN, M. 1996. Drawing high de-gree graphs with low bend numbers. InProceedings of the 3rdInternational Symposium on Graph Drawing (GD95), Springer,F. J. Brandenburg, Ed., vol. 1027 ofLNCS, 254266.

    FRICK, A. 1997. Upper bounds on the number of hidden nodesin sugiyamas algorithm. InProceedings of the 4th InternationalSymposium on Graph Drawing (GD96), Springer, vol. 1190 ofLNCS, 169183.

    GANSNER, E . , KOUTSOFIOS , E., NORTH, S., AN D VO, K.-P.1993. A technique for drawing directed graphs. IEEE Transac-tions on Software Engineering 19, 3, 214230.

    GAREY, M. R., A ND J OHNSON, D. S. 1979. Computers and In-tractability, A guide to the theory of NP Completeness . Freeman,New York.

    GAREY, M. R., A ND J OHNSON, D. S. 1983. Crossing number isNP-complete.SIAM Journal on Algebraic and Discrete Methods

    4, 312316.KAUFMANN, M., AN D WAGNER, D., Eds. 2001. Drawing

    Graphs: Methods and Models. LNCS Tutorial. Springer.

    KLAU , G. W., A NDMUTZEL, P. 1998. Quasi-orthogonal drawingof planar graphs. Tech. Rep. 98-1-013, Max-Planck-Institut frInformatik, Saarbrcken.

    KLAU , G. W., KLEIN, K., AN DMUTZEL, P. 2001. An experimen-tal comparison of orthogonal compaction algorithms (extendedabstract). InProceedings of the 8th International Symposium onGraph Drawing (GD00), Springer, vol. 1984 ofLNCS, 3751.

    OMG, 2004. UML 2.0 superstructure specification.

    (accessed April 5, 2006).

    14

  • 8/11/2019 How to draw an Activity Diagram

    16/18

    PACH , J., AND W ENGER, R. 1998. Embedding planar graphs atfixed vertex locations. In Proceedings of the 6th InternationalSymposium on Graph Drawing (GD98), Springer, vol. 1547 ofLNCS, 263274.

    PURCHASE, H. C., COHEN, R. F., AN D JAMES, M. 1997. Anexperimental study of the basis for graph drawing algorithms.

    ACM Journal of Experimental Algorithmics 2, 4.PURCHASE, H. C. 1997. Which aesthetic has the greatest effect on

    human understanding? InProceedings of the 5th InternationalSymposium on Graph Drawing (GD97), Springer, vol. 1353 ofLNCS, 248261.

    SANDER, G. 1996. Layout of compound directed graphs. Tech.Rep. A/03/96, Universitt des Saarlandes, FB 14 Informatik,66041 Saarbrcken, June.

    SHEGOGUE, D., A NDZHENG, W. J. 2005. Integration of the geneontology into an object-oriented architecture. BMC Bioinformat-ics 6, 113.

    SIEBENHALLER, M., AND KAUFMANN, M. 2006. Mixed up-ward planarization - fast and robust. In Proceedings of the 13thSymposium on Graph Drawing (GD05), Springer, vol. 3843 ofLNCS, 522523.

    SIX , J. M., AN D TOLLIS, I. G. 2002. Automated visualizationof process diagrams. In Proceedings of the 9th InternationalSymposium on Graph Drawing (GD01), Springer, vol. 2265 ofLNCS, 4559.

    SUGIYAMA, K. , TAGAWA, S. , AND TODA , M. 1981. Meth-ods for visual understanding of hierarchical system structures.IEEE Transactions on Systems, Man, and Cybernetics SMC-11,2, 109125.

    TAMASSIA, R., BATTISTA, G. D., A ND BATINI, C. 1988. Auto-matic graph drawing and readability of diagrams. IEEE Trans-actions on Systems, Man and Cybernetics 18, 1, 6179.

    TAMASSIA, R . 1987. On embedding a graph in the grid with theminimum number of bends. SIAM Journal on Computing 16, 3,421444.

    WAGNER, F., A ND WOLFF, A . 1998. A combinatorial frameworkfor map labeling. InProceedings of the 6th International Sympo-sium on Graph Drawing (GD98), Springer, vol. 1547 ofLNCS,316331.

    WIESE, R . , EIGLSPERGER, M., AND KAUFMANN, M. 2002.yfiles: Visualization and automatic layout of graphs. In Pro-ceedings of the 9th International Symposium on Graph Drawing(GD01), Springer, vol. 2265 ofLNCS, 453454.

    WITTENBURG, K., AND WEITZMAN, L. 1997. Qualitative vi-

    sualization of processes: Attributed graph layout and focusingtechniques. In Proceedings of the 4th International Symposiumon Graph Drawing (GD96), Springer, vol. 1190 ofLNCS, 401408.

    15

  • 8/11/2019 How to draw an Activity Diagram

    17/18

    Figure 16: UML activity diagram drawn with our new layout approach. It shows another view of the example of Figure 1.

    1 Request

    product 3

    Continuework

    Processorder

    Pullmaterials

    Order

    Shiporder

    11

    Order

    12 Bill

    customer

    Receiveorder

    14 Bill

    Paybil l

    7 Bill

    Closeorder

    Lane 1

    Lane 2

    Lane 3

    specification

    Figure 17: Another UML activity diagram taken from the Schematic tool page (http://www.hypergraphics.co.uk).

    16

  • 8/11/2019 How to draw an Activity Diagram

    18/18

    Figure 18: Our layout approach applied to a process diagram. The diagram was taken from the CABIE project page (http://cabie.tigris.org).

    17