Entity Modelling

www.entitymodelling.org - entity modelling introduced from first principles - relational database design theory and practice - dependent type theory


Representing Graphs

In this section we discuss various ways of representing directed graphs, the different shapes that their entity models can take and the different organisations of information implied by the different shapes.

Directed Graphs

There is a reliance here, in this presentation, on the use of the work 'abstract' and on an understanding of what the mathematician means by this. The best that I can offer as explanation is that the mathematical idea of an abstract structure is that of a set of individuals and relations independent of any particular representation of the individuals and the mathematical concepts of graph and directed graph are cases in point. In the case of a graph the individuals are notionally vertices and edges and the relations are the incidence relations between them. It is certainly ironic and perhaps at first sight paradoxical, but with regard to any particular abstract structure, to describe it we need some kind of representation even though what we seek to describe is something without any particular representation. Mathematican Robin Gandy describes this to a non-mathematical audience in a lecture 'Structure in Mathematics' 1; he draws the love relationships to be found in Iris Murdoch's novel Severed Head as a directed graph and I have drawn an equivalent graph in figure 25. If we abstract a directed graph from this then there are no labels, no lines, no points on paper just the facts of a set of notional individual entities and ther relationships between them2.

Figure 26
Example from 'Structure in Mathematics' of a directed graph showing the love relationships to be found in Iris Murdoch's novel 'Severed Head' . The labels on the graph are simply to show the correspondence with the novel.
pLh
hLp
aLp
pLa
pLg
mLp
mLh
aLx
xLa
gLx
gLm
mLg
Table 2
Gandy's relational depiction of the same love relationships.

As an illustration of different representations of the same abstract structure, Gandy gives the relational representation shown in table 2. In the relational representation, p occupies the same structural position as PALMER, h as HONOR, a as ANTONIA, g as GEORGIE, m as MARTIN, x as ALEXANDER.

Gandy's depicted love relationship is a many-many relationship and we can represent in an entity model like this:

Equivalently in the technical vocabulary but with the same shape we have the entity model of a directed graph shown in figure 27

Figure 27
The model of a directed graph.

There is of course nothing special about this example - loves is a recursive many-many relationship and any such could be used to illustrate that a recursive many-many relationship is structurally a directed graph.

Gandy's relational representation shown in figure 25 could be rearranged in two ways — from the point of view of the lover or the loved; these are shown in figures 28 and 29.

aLp,x
gLx,m,g
hLp
mLp,h,g
pLh,a,g
xLa
Figure 28
From this representation you may quickly find who is loved by a, who is loved by g and so on.
x,pLa
m,pLg
m,pLh
gLm
h,mLp
a,gLx
Figure 29
From this representation you may quickly determine who loves a, who loves g and so on.

ER Models of Directed Graph

Viewing figures 29 and following on from figure 29 we see that there are two further ways of modelling directed graphs. These are shown in figure 30 and 31.

Figure 30
Directed Graph ER Model (ii)
Figure 31
Directed Graph ER Model (iii)

Though we have given three ways of modelling directed graphs note that mathematically there is only a single concept. The different models represent different ways of localising and communicating the information content of a graph. The models in figures 30 and 31 vary the incidence relationships between edges and vertices between categories reference and composition. If both are made composition then we get a further variation which is shown in figure 32.

Figure 32
Directed Graph ER Model (iv)

But what communication structure do we associate with this? Well, this way of modelling directed graphs is akin to the matrix structure modelled in chapter one. Applied to the representation of the Severed Head love relationships it implies a communication in which it is apparent both (i) who loves each subject a,g,h and so on and (ii) who each subject a,g,h, etc. is loved by. This is made apparent by a matrix representation:

a g h m p x
a x x
g x x
h x x
m
p x x x x
x x x

We mentioned in chapter one that information is usually hierarchically communicated whereas with double composition relationships there is not one hierarchy but two hierarchies. Information must be double communicated once in each hierarchical form. For linear, hierarchical communication the above model is therefore replaced by one in which each of the two hierarchies is represented as shown in figure 33.

Figure 33
Directed Graph ER Model (v)

Modelling Graphs and Symmetric Relationships

We use the unqualified term graph to mean a set of vertices and a set of undirected connections or edgess between them. To the mathematician the definition is straightforward but to the entity modeller it is less so and is somewhat unsatisfying. There is a difficulty and this difficulty lies at the heart of entity modelling. An understanding of the difficulty reveals simultaneously a gap in the entity relational approach by comparison with the mathematical approach but also an affinity between it and the means of language and communication.

To model a bidirectional graph is to add a reverse relationship to any of the models of a directed graph. If we start from figure 30 then we get this model:

In this model we have greyed out the to relationship to show that it has become redundant. This is because the vertex that an exit leads to is always the same vertex that its reverse leads from.


1In Structuralism, edited by D. Robey, Wolfson College Lectures, 1972.
2According to Gandy: This indifference to form of representation is what Bertrand Russell referred to when he said that in mathematics we are not interested in what we are talking about. We return to the subject abstraction versus representation in a later section.