Simplify patterns 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 ShortcutSubpanelPattern

For a 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.

Optionally, you can add properties to the new shortcut relationship to include key information from the original pattern:

06 06 01 ShortcutPropertyOptions
  • Count paths and store count on relationship adds a new property showing how many edges were shortcut.

  • Add a center node property to the new relationship lets you create a new property and select a preset or custom formula to compute its values, based on a property available on the center category (B) nodes.

Formulas for properties added to 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)

Create a Shortcut

Using the graph pattern for photo assets illustrated above as an example, we can shortcut the Photos category to connect Authors directly to the Locations where they took an image through a new WORKED_AT relationship.

To create a shortcut:

  1. Open the Transform panel and Shortcut subpanel.

    The graphic at the top shows a starting pattern which is updated as you enter the required shortcut details.

  2. In Match, select the details for the shortcut pattern from the dropdown menus:

    • R1 (Relationship 1): select TAKEN_BY and its relationship direction.

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

    • R2 (Relationship 2): select TAKEN_AT and its relationship direction.

  3. In Create, enter the name for the new shortcut relationship R3: enter WORKED_AT.

    06 06 02 ShortcutMatchCreate
  4. In Options you can:

    • Click Count paths and store count on relationship to add a new property showing how many edges were shortcut. Here, the default pathCount property on the new (WORKED_AT) edges indicates how many Photos were taken by an Author at a particular Location. Optionally, you can edit the default property name to make it more descriptive.

    • Click Add a center node property to the new relationship, then:

      • Select one or more properties from the dropdown menu and optionally, edit the property name for the new computed property.

      • Select the preset or custom formula used to compute the value of the new property.

        Presets use the current selections for center node and property, and a standard preset calculation. You can click Edit formula to open a text box to edit the selected formula, but you don’t need to unless you want the result calculated differently (for example, to exclude outliers) or returned in a different format. Editing a preset automatically turns it into a custom formula.

        For example, to add an average rating for Photos taken at each Location to each WORKED_AT edge, we select the Rating property from the dropdown menu, select the average preset from the dropdown menu, and leave the default property name as averageRating.

        06 06 03 ShortcutOptionsRun
  5. Click the Run button at the bottom of the subpanel. It shows the number of nodes involved. Logs below the Run button show progress and error messages.

    The new shortcut edges are added to the graph on the canvas. The source pattern is still present (in this example, the Photos nodes and their TAKEN_AT and TAKEN_BY edges).

    06 06 04 ShortcutNewEdges
  6. Click the central category (e.g. Photos) on the legend to select and hide (right-click Actions>Hide or Hide Selected on the toolbar) or delete the nodes (right-click Delete, Delete on the toolbar, or del or backspace key).

    06 06 05 ShortcutHidePhotos

    The source pattern (nodes and the connected edges) is now hidden (or deleted).

    06 06 06 ShortcutOnly
  7. To see the properties added to the new edges, display an info panel or quick info rollover for an edge, or open a table of the edges for the new relationship (e.g. WORKED_AT).

    06 06 07 ShortcutRelPropsInfo