Sometimes we don’t care about the direction of a link when identifying matching subgraphs. For example, we might care only that a path exists between two objects, but not about the direction of that path. In such a case, we want to create a query that requires that two objects be linked, but that doesn’t require a specific direction for that link.
An undirected edge in a QGraph query indicates that there must be a link between the corresponding database objects without concern for the direction of that link. To see how this affects query results, let’s look at the following sample database and query. Figure 2.8 shows a fragment of a database containing information about Web pages and their connections.
Figure 2.9 is a simple query designed to find sets of two linked objects. Because we don’t care whether the link goes from A to B or vice versa, we use an undirected edge to represent that connection.
The results of running this query on the above database fragment are shown in Figure 2.10.
Ignoring link direction lets this query
match any pair of objects as long as those objects have a link
connecting them. As we saw before, QGraph finds as many
matches as it can, including subgraphs that duplicate the elements of
another match but that map those database elements to different query
elements.
In this example, we have two subgraphs that include the
linked objects home.html and
page1.html. In one subgraph,
home.html matches vertex
A; in the other it matches vertex
B. The link matching edge
X always follows its direction in the
database (from home.html to
page1.html), even though it points from
A to B in
one subgraph and from B to
A in the other.