Skip to content

2. Drawing linear arrangements

Lluís Alemany Puig edited this page Jan 29, 2022 · 2 revisions

With head vectors

Quite interestingly, head vectors already carry in them information about the position of each vertex. Therefore, the input

(1) head of node:   2 3 4 1
    index of node:  1 2 3 4

will produce 4 dots and 4 arcs, one connecting the first and second dot (node 1's parent is node 2), another connecting the second and the third, the third and the fourth and, lastly, the fourth and the first (since node 4's parent is node 1). The figure produced is the following

Right below the arrangement we find two rows of numbers: the first are the labels of the nodes (being from 1 to n (the number of nodes) by the default) -- these will be found more useful in later sections of this wiki. The second row are the positions of the nodes, which simple serve as a guide to the eye. Furthermore, in the current version of this ipelet, the arcs can't be drawn with arrows.

Now, if we replace node 4's parent (node 1) with a zero, i.e.,

    head of node:   2 3 4 0
    index of node:  1 2 3 4

the ipelet will only draw 3 arcs since node 4 has no parent. The resulting arrangement is

The circled dot in the figure marks the only node with no head, i.e., the only node with a 0 in the head vector. Recall that there can be more than one node with no head. Example (2) in Section 2 produces the following arrangement:

These circles are only produced if the ipelet received a head vector as input.

With edge lists

Edge lists are a bit simpler than head vectors. Nevertheless, these still carry information about the positions of the nodes.

As explained in Section 2, each edge is given as a pair of nodes, each of which is, obviously, represented with a number. These numbers, besides labelling nodes with a known index, they also provide information about their positions. Therefore, the example (1) can be given to the ipelet as an edge list as

1 2 2 3 3 4 4 1

The order of the nodes is not taken into account in the current version of this ipelet. This edge list produces the exact same arrangement than its corresponding head vector 2 3 4 1.

Edge lists have the clear advantage that with them we can draw more complicated graphs. For example, the edge list

1 2 1 3 1 4 2 3 2 4 3 4

represent the edges of a complete graph of 4 vertices.

In an edge list input, we don't need to start labelling the vertices with 1. In fact, we can use any indices we like. However, the ipelet will consider that the graph has as many vertices as the largest index given. Thus, the edge list

11 12 11 13 11 14 12 13 12 14 13 14

will produce a linear arrangement of 14 vertices, only the last four of which have some incident edge. Notice that these edges are much like the edges in the example above but just moved some positions up the arrangement.