User Guides
Transforming Graph Data
Using 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.

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

PresetFunctionFormat
customEditable format(centerNodePropValues) => .join(centerNodePropValues,"")
take firstCopies the first value of another property(centerNodePropValues) => _.size(centerNodePropValues) > 0 ? centerNodePropValues[0] : null
countCalculates a value based on number of connections.(centerNodePropValues) => _.size(centerNodePropValues)
sumSums the values of the selected property.(centerNodePropValues) => _.sumBy(centerNodePropValues,d => Number(d) | 0)
averageAverages the values of the selected property.(centerNodePropValues) => .sumBy(centerNodePropValues,d => Number(d) | 0)/(.size(centerNodePropValues) > 0 ? _.size(neighborPropValues) : 1)
rangeFinds the lowest and highest value of the selected property.(centerNodePropValues) => ${_.maxBy(centerNodePropValues, d => Number(d) | 0)} - ${_.minBy(centerNodePropValues, d => Number(d) | 0)}
maxFinds the maximum value of the selected property.(centerNodePropValues) => _.maxBy(centerNodePropValues, d => Number(d) | 0)
minFinds 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.

For a hands-on tutorial using a larger dataset, see How to GraphXR: Shortcut (opens in a new tab).

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. For (B) (Center Category), select Photos.
    B (Center Category), select Photos.
    R2 (Relationship 2), select TAKEN_AT.
    R3 (Relationship 3, i.e. the new shortcut relationship), enter WORKED_AT.

  3. 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.

  4. Click Run. Processing messages display below the Run button indicating success or errors.

    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.

  5. To view the shortcut graph, click the Photos category on the legend to select its nodes.

  6. Then either click the Hide Selected icon to hide all the Photos nodes, or press 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.

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).