Assigning values

Given the following graph, how do we assign a value for Daniel's age?



Assigning values to a path

One option is to allow a value to be assigned to a path of the graph. For example, the path:

Daniel -> person -> age

... could be assigned the value 27.

Although simple and intuitive, this approach abandons the directed graph representation, since there is no direct way to represent a path in a graph having a value.

A directed graph representation

We can stick with our directed graph representation as follows:



Notice that the value assignment involves a relationship within a relationship: The entity "Daniel" is related to "age", and the definition of that relationship instance is an equality relationship with "27".

This works, but is more complex than seems necessary. In terms of the graph representation, it can be represented by:

Daniel x age
x = 27

Where x is a new, un-named node. Note also that here, = does not represent any new notation and instead is simply a relation between two things uniquely referenced by the = keyword.

An alternative graph representation



This representation is simpler, and can be represented using two directed connections:

Daniel -> 27
27 -> age

It also allows us to represent values for has:n relationships quite easily. For example:



ie.Daniel has two sisters, Rebekah and Hannah.

A textual representation

For ease of use, we'll define value assignment as:

Daniel.age = 27

In cases where more than one value is required, we'll use:

Daniel.sister[0] = Rebekah
Daniel.sister[1] = Hannah

Note that at the moment this is a bit dishonest since there is no inherant order in multi-values for how they are being represented in the graph.

A note about node labels

To make graphs readable, we have been labeling nodes with their associated keyword. But this is merely an aid for the reader, and is not a part of the representation itself. Thus, our current representation is more acturately graphed as follows:



This raises an important point: Until we connect our representation to language in some way shape or form, it can't do very much.

A note about collisions

Consider the following:

Daniel.first_name = Daniel

This is a circular reference, since the "Daniel" entity is used twice. The problem is that the two references to "Daniel" are actually intended to reference different things:

1.The first use is intended to reference the entity Daniel which is a person
2.The second use is intended to reference the entity Daniel which is a word (a string of characters)

This highlights how using keywords to uniquely identify entities becomes tricky due to collisions. It also hints at the need already to connect our representation with language, since "Daniel" is a string of characters. ie. A word.