Elsevier

Computational Geometry

Volumes 105–106, August–October 2022, 101886
Computational Geometry

Layered drawing of undirected graphs with generalized port constraints

https://doi.org/10.1016/j.comgeo.2022.101886Get rights and content

Abstract

The aim of this research is a practical method to draw cable plans of complex machines. Such plans consist of electronic components and cables connecting specific ports of the components. Since the machines are configured for each client individually, cable plans need to be drawn automatically. The drawings must be well readable so that technicians can use them to debug the machines. In order to model plug sockets, we introduce port groups; within a group, ports can change their position (which we use to improve the aesthetics of the layout), but together the ports of a group must form a contiguous block.

We approach the problem of drawing such cable plans by extending the well-known Sugiyama framework such that it incorporates ports and port groups. Since the framework assumes directed graphs, we propose several ways to orient the edges of the given undirected graph. We compare these methods experimentally, both on real-world data and synthetic data that carefully simulates real-world data. We measure the aesthetics of the resulting drawings by counting bends and crossings. Using these metrics, we experimentally compare our approach to Kieler [JVLC 2014], a library for drawing graphs in the presence of port constraints. Our method produced 10–30 % fewer crossings, while it performed equally well or slightly worse than Kieler with respect to the number of bends and the time used to compute a drawing.

Introduction

Today, the development of industrial machinery implies a high interdependency of mechanical, electrical, hydraulic, and software-based components. The continuous improvement of these machines yielded an increased complexity in all these domains, but also in their interrelations. In the case of a malfunction, a human technician needs to understand the particular interdependencies. Only then, (s)he will be able to find, understand, and resolve errors. Different types of schematics play a key role in this diagnosis task for depicting dependencies between the involved components, e.g., electric or functional schematics. The intuitive understanding and comprehensibility of these schematics is critical for finding errors efficiently.

Due to the increased complexity of machinery, such schematics cannot be drawn manually anymore: The high variance of machine configurations nowadays requires the ad-hoc computation and visualization of schematics appropriate for the requested diagnosis case. To support technicians, algorithms for drawing schematics should adhere to the visual “laws” of the manual drawings that the technicians are familiar with; see Fig. 1 for an example. Such drawings route connections between components in an orthogonal manner. Manual drawings often use few layers and seem to avoid crossings and bends as much as possible.

In many applications (such as UML diagrams or data flow diagrams), connections are directed from left to right or from top to bottom. This setting is supported by the framework introduced by Sugiyama et al. [1]. Given a directed graph, their approach arranges the edges mainly in the same direction by organizing the nodes in subsequent layers (or levels). The layer-based approach solves the graph-layout problem by dividing it into five phases: cycle elimination, layer assignment, crossing minimization, node placement, and edge routing.

There are also algorithms for practical applications purely based on the orthogonal drawing paradigm, where all vertices are rectangles on a regular grid and the edges are routed along the horizontal and vertical lines of the grid. There, a classic three-phase method dates back to Biedl et al. [2].

In many technical drawings (such as cable plans, UML diagrams, or data flow diagrams), components are drawn as axes-aligned rectangles, connections between the components are drawn as axes-aligned polygonal chains that are attached to a component using a port, that is, a geometric icon that is small relative to a component and whose shape has a specific meaning for the domain expert. Using so-called port constraints, a user can insist that a connection enters a component on a specific side—a natural requirement in many applications.

The well-established Kieler library [3] implements the Sugiyama framework. Kieler is particularly interesting for our application as Kieler allows the user to specify several types of port constraints; namely, on which side of a vertex rectangle should a port be placed, and, for each side, the exact order in which the ports should be arranged. Alternatively, the order is variable and can be exploited to improve the layouts in terms of crossings and bends. Okka et al. [4] integrate these types of port constraints to a force-directed layouting algorithm.

We have chosen to build our algorithm for undirected graphs on the (directed) layer-based approach instead of an (undirected) purely orthogonal one because the typical hand-drawn plans use only few distinct layers to place the vertices on, the layer-based approach seems to be better investigated in practice, and Kieler has already proven to yield by and large pleasing results in the considered domain.

Our contribution  First, we propose two methods to direct the edges of the given undirected graph so that we can apply the Sugiyama framework (see Section 3); one is based on breadth-first search, the other on a force-directed layout. We compare the two methods experimentally with a simple baseline method that places the nodes of the given graph randomly and directs all edges upward (see Section 4.3), both on real-world and synthetic cable plans (see Section 4.2). We claim that our approach to generate realistic test graphs is of independent interest. We “perturb” real-world instances such that, statistically, they have similar features as the original instances.

Second, we extend the set of port constraints that the aforementioned Kieler library allows the user to specify. In order to model plug sockets, we introduce port groups; within a group, the position of the ports is either fixed or variable. In either case, the ports of a group must form a contiguous block. Port groups can be nested. If the order of a port group is variable, our algorithm exploits this to improve the aesthetics of the layout.

Apart from such hierarchical constraints, we also give the user the possibility to specify pairings between ports that belong to opposite sides of a vertex rectangle (top and bottom). Such a pairing constraint enforces that the two corresponding ports are placed at the same x-coordinates on opposite sides of the vertex rectangle. Pairing constraints model pairs of sockets of equal width that are plugged into each other.

After formally defining the problem (Section 2), we describe our algorithm (Section 3). Finally, we present our experimental evaluation (Section 4).

Section snippets

Preliminaries

We define the problem Layered Graph Drawing with Generalized Port Constraints as follows. For an illustration refer to Fig. 3b.

Given: An undirected port graph G, which is a 5-tuple (V,P,PG,PP,E), where

  • V is the set of vertices—each vertex v is associated with two positive numbers w(v) and h(v); v will be represented by a rectangle of width at least w(v) and height at least h(v) (to ensure a given vertex label can be accommodated),

  • P is the set of ports—each port belongs either directly to a

Algorithm

We assume that we are given a graph as described in Section 2. (Otherwise we can preprocess accordingly.) Similarly to the algorithm of Sugiyama et al. [1], our algorithm proceeds in the following phases, which we treat in the next subsections. For a small but complete example, see Fig. 2.

    Phase 1:

    Orienting undirected edges. We orient the undirected edges by drawing the underlying simple graph with a force-directed graph drawing algorithm and then direct all edges upwards. Alternatively, we may

Experimental evaluation

For our experiments we got access to 380 real cable plans of a large German machine manufacturing company (and another smaller data set; see Section 4.3). To obfuscate these plans and to have more data for our experiments, we generated 1140 pseudo cable plans from the real cable plans—three from each real cable plan. For replicability, we have made all of our algorithms, data structures, and data described here publicly available on github [13], [14]—except for the original (company-owned)

Discussion and conclusion

In this section, we discuss the findings of our experiments in regards of the following aspects.

Declaration of Competing Interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

References (18)

  • C.D. Schulze et al.

    Drawing layered graphs with port constraints

    J. Vis. Lang. Comput.

    (2014)
  • P. Eades et al.

    Drawing graphs in two layers

    Theor. Comput. Sci.

    (1994)
  • K. Sugiyama et al.

    Methods for visual understanding of hierarchical system structures

    IEEE Trans. Syst. Man Cybern.

    (1981)
  • T.C. Biedl et al.

    The three-phase method: a unified approach to orthogonal graph drawing

    Int. J. Comput. Geom. Appl.

    (2000)
  • A. Okka et al.

    CoSEP: a compound spring embedder layout algorithm with support for ports

    Inf. Vis.

    (2021)
  • U. Brandes et al.

    Fast and simple horizontal coordinate assignment

  • U. Brandes et al.

    Erratum: Fast and simple horizontal coordinate assignment

  • T.M.J. Fruchterman et al.

    Graph drawing by force-directed placement

    Softw. Pract. Exp.

    (1991)
  • F. Lipp et al.

    Faster force-directed graph drawing with the well-separated pair decomposition

    Algorithms

    (2016)
There are more references available in the full text version of this article.

Cited by (7)

View all citing articles on Scopus
1

J.Z. acknowledges support by BMWi (ZIM project iPRALINE – grant ZF4117505).

View full text