Working with Vertices and Edges

Vertices and edges are the foundation of QGraph queries. All queries must contain at least one vertex. Queries with multiple vertices must form a connected graph.

To add a vertex:

To add new vertices to a query, enter vertex mode and use the mouse to position the new vertex.

  1. In the Query Editor toolbar, click or press Ctrl-2 to choose the vertex tool and enter vertex mode. The Query Editor remains in vertex mode (all clicks in the Query Editor display area create a new vertex) until you change modes by choosing a different tool from the toolbar.

  2. Click in the Query Editor display area. The Query Editor creates a new vertex.

  3. [Optional] Provide a name for the new vertex. (Alternatively, you can continue using the default name provided by the Query Editor.)

    1. In the Query Editor toolbar, click or press Ctrl-1 to choose the selection tool and enter selection mode.

    2. Click the vertex to be re-named. The Query Editor displays the vertex’s properties in the element properties pane.

    3. In the element properties pane, click the current (default) name for this vertex. Edit the name and press Tab or Return.

To add an edge:

To add new edges to a query, enter edge mode and use the mouse to draw the new edge.

  1. In the Query Editor toolbar, click or press Ctrl-3 to choose the edge tool and enter edge mode. The Query Editor remains in edge mode (clicks in the Query Editor display area create a new edge) until you change modes by choosing a different tool from the toolbar.

  2. Drag the mouse from one vertex to another vertex. The Query Editor creates a directed edge from the starting vertex to the ending vertex.

  3. [Optional] Provide a name for the new edge. (Alternatively, you can continue using the default name provided by the Query Editor.)

    1. In the Query Editor toolbar, click or press Ctrl-1 to choose the selection tool and enter selection mode.

    2. Click the edge to be re-named. The Query Editor displays the edge’s properties in the element properties pane.

    3. In the element properties pane, click the current (default) name for this edge. Edit the name and press Tab or Return.

Edges may be directed or undirected. Directionality is an edge property and is set in the element properties pane.

To add an undirected edge:

  1. Create a directed edge.

  2. Click or press Ctrl-1 to choose the selection tool.

  3. Click the edge to be modified

  4. In the element properties pane, change the value of Is Directed from true to false.

  5. Press Tab or Return.

To change edge direction:

  1. Click or press Ctrl-1 to choose the selection tool.

  2. Click the edge to be modified.

  3. In the Edit menu, choose Flip Edge Direction or press Ctrl-F.

A self-link edge connects a single vertex to itself and matches links in the database that connect an object to itself.

To add a self-link (loop) edge:

  1. Click to choose the edge tool.

  2. Click the target vertex without dragging. The Query Editor creates an edge that begins and ends at the target vertex (a self-link or loop edge).

To select a query element:

Use selection mode to re-position query elements in the display and to select existing query elements for editing, such as adding or modifying conditions and annotations on that element.

  1. In the Query Editor toolbar, click or press Ctrl-1 to choose the selection tool and enter selection mode.

  2. Click the query element you want to select. The Query Editor draws handles around the selected element.

The Query Editor remains in selection mode (clicks in the Query Editor display select query elements) until you change modes by choosing a different tool from the toolbar.

To delete a vertex or edge:

Deleting a vertex also deletes any edges linked to that vertex. Make sure that your query remains connected after deleting any elements.

  1. Click or press Ctrl-1 to choose the selection tool.

  2. Click the element to be deleted.

  3. Press Delete.

To add or edit a condition:

Conditions and annotations are properties of a specific vertex or edge. Select the element to be modified and use the element properties pane to add or edit any conditions or annotations on that element.

Complex conditions must be entered using disjunctive normal form in prefix notation. See “Complex conditions in Proximity” for additional information on entering complex conditions in the Query Editor.

  1. Click or press Ctrl-1 to choose the selection tool.

  2. Click the vertex or edge that requires a condition.

  3. In the element properties pane, click in the Value column for Condition.

  4. Enter the new condition or edit the value of the current condition.

  5. Press Tab or Return.

To add or edit an annotation:

All edges adjacent to an annotated vertex must also be annotated. To help avoid validation errors due to unannotated edges, you can elect to automatically add a [1..] annotation to any new edge (see To change automatic annotation preferences, below, for instructions).

  1. Click to choose the selection tool and select the vertex or edge to be annotated.

  2. In the element properties pane, click in the value column for Annotation.

  3. Enter the annotation text.

  4. Press Tab or Return.

To change automatic annotation preferences:

The Query Editor provides the option of automatically annotating every new edge with [1..]. Because edges adjacent to annotated vertices must be annotated, adding this annotation automatically can help to prevent validation errors. The [1..] annotation is the most common edge annotation and is typically the correct edge annotation for most queries involving annotated vertices. Adding a [1..] annotation to edges that are not adjacent to annotated vertices is rarely a problem for most datasets, although care should be taken to understand how this differs from unannotated edges when the dataset contains instances of multiple links connecting two objects.

Selecting the Add [1..] To New Edges command toggles the automatic edge annotation behavior: