Simplifying paths with Shortcut

The Shortcut transform connects two nodes that share a common neighbor with a new edge, and in the process creates a new relationship. The source pattern remains, but it can be hidden or deleted. This enables you to simplify a graph without merging nodes.

06 06 00 ShortcutPattern

Generally, for the pattern:

(Category A)→[Relationship 1]→(Category B)→[Relationship 2]→(Category C)

a new shortcut pattern is created:

(Category A)→[New Relationship3]→(Category C), where:

  • Categories A, B, and C contain nodes that share a common neighbor,

  • [Relationship1] and [Relationship2] contain edges of the two relationships, and

  • [Relationship3] contains edges of the new shortcut relationship. If desired, you can select one or more properties from the center category (Category B) to be added to the new [Relationship3]. You can also transform the property values using a preset (or custom) Input Formula.

Preset formulas for properties of a Shortcut relationship

Preset Function Format

custom

Editable format

(centerNodePropValues) => .join(centerNodePropValues,"")

take first

Copies the first value of another property

(centerNodePropValues) => _.size(centerNodePropValues) > 0 ? centerNodePropValues[0] : null

count

Calculates a value based on number of connections.

(centerNodePropValues) => _.size(centerNodePropValues)

sum

Sums the values of the selected property.

(centerNodePropValues) => _.sumBy(centerNodePropValues,d => Number(d) | 0)

average

Averages the values of the selected property.

(centerNodePropValues) => .sumBy(centerNodePropValues,d => Number(d) | 0)/(.size(centerNodePropValues) > 0 ? _.size(neighborPropValues) : 1)

range

Finds the lowest and highest value of the selected property.

(centerNodePropValues) => ${_.maxBy(centerNodePropValues, d => Number(d) \| 0)} - ${_.minBy(centerNodePropValues, d => Number(d) \| 0)}

max

Finds the maximum value of the selected property.

(centerNodePropValues) => _.maxBy(centerNodePropValues, d => Number(d) | 0)

min

Finds the minimum value of the selected property.

(centerNodePropValues) => _.minBy(centerNodePropValues, d => Number(d) | 0)

Editing a preset moves it to the custom item, where you can test or run the edited formula.

Creating a Shortcut

Using the graph pattern for photo assets illustrated above as a basic example, we can use a shortcut pattern to connect Authors (i.e. photographers) directly to the Locations where they took an Image through a new WORKED_AT relationship.

06 06 01 ShortcutPhotos720
For a hands-on tutorial using a larger dataset, see our How to GraphXR tutorials.

To create a Shortcut:

  1. Open the Transform panel and Shortcut tab.

  2. Now enter the following details in the Shortcut panel:

    • R1 (Relationship 1): select CREATED.

    • (B) (Center Category): select Photos.

    • R2 (Relationship 2): select TAKEN_AT.

    • R3 (Relationship 3, i.e. the new shortcut relationship): enter WORKED_AT.

    • If desired, you can copy properties from the central category (Photos) to the new (WORKED_AT) relationship, and transform the property values using an Input Formula.
      We’ll compute an average rating for the photos taken at each location, and add it as a new averageRating property of the WORKED_AT relationship.

      • Select the Rating property from the dropdown menu to add it to the Selected Property list.

    • Enter a New Property Name (averageRating).

    • In Input Formula, select average, and edit the input formula to:

      (Rating) => .sumBy(Rating,d => Number(d) || 0)/(.size(Rating) > 0 ? _.size(Rating) : 1)
    • Check the Directional Edge and Count Links checkboxes. Count Links adds an automatic count property to the new relationship which may not always be meaningful. In this example though, it represents the number of photos at a location taken by the connected author.

      06 06 02 ShortcutEnterDetails1320
  3. Click Run. Error and completion messages appear below the Run button.

    06 06 03 ShortcutRunMessage720

    The new shortcut pattern has now been created and added to the graph. Note that the source pattern with its Photos nodes are still present in the graph space.

  4. To see the shortcut graph, click the Photos category on the legend to select its nodes.

    06 06 04 ShortcutNewEdges720
  5. Either click the Hide Selected icon to hide all the Photos nodes, or the Delete icon (or del or backspace) to delete them from the graph.

    We now see only Author and Location nodes connected by the new WORKED_AT edges.

  6. To see added properties, you can display an info panel or quick info rollover for one of the new edges, or display a table of the edges for the new relationship (e.g. WORKED_AT).

    06 06 05 ShortcutOnly720