In this Session…

Before you begin…

  • Using Transforms:

    • f(x) and Link to reformat and reorganize data.

    • Aggregate to enumerate and/or evaluate nodes or edges.

    • Merge to merge nodes or edges.

To follow along, download the files:





How To GraphXR 5. Aggregate and Merge


Before You Begin…

Ideally, you’ll have worked through Module 4. Link and Filter. If you’re starting here, and you want to follow along, you’ll need to:

  • Log in to GraphXR, create a Project, and open its graph space. 

  • Download the file, which contains the Game of Thrones data we’ll use in our tutorials.

  • Drag and drop the file 05_START.graphxr onto the space.


So far, we’ve extracted a House category from the Characters.csv data, created a belongs_to relationship with Character nodes, and a spoke relationship between Characters and the Lines they spoke. 


Now drag and drop Episodes.csv onto the graph space. Episodes, our new category, contains the titles, descriptions, air dates, episode numbers, season numbers, and viewership for each episode. We want to link corresponding lines and episodes.


We have a little problem, though. In Lines, season and episode number are combined into the single string seasonEpisode. In Episodes, they occupy separate properties.


To fix this, we’ll use the Transform panel => f(x) tab. The f(x) transform lets us perform javascript formulas on a single category or relationship. Several presets are included, but for this we’ll need to enter a custom formula.


Select Episodes and episodeNumber. Input

“(propVal,props) => 'S'+props.seasonNumber+'E'+props.episodeNumber”

as the custom formula and seasonEpisode as the new property name. 

Note the example result automatically calculated under the New Property Name


Click Run and the results appear below.


Now that we have matching values, we can link up Episodes and Lines in the Link tab using the seasonEpisode property.


Next, let’s calculate the total number of lines per episode. Go to the Transform panel => Aggregate tab (after taking a Snapshot for good measure!). The Aggregate transform retrieves properties from a selected node’s connected edges or neighbor nodes, applies a formula to those properties, then writes the results back to the selected node.


Here we’re starting with our Episodes and following spoken_on to find lineCount values. We can use the sum preset to add those values together and then write the result back to Episodes nodes as a new value called totalLines.


And here we’ll perform a count of Episodes spoken_on connections and write the result back to Episodes nodes as totalCharacters.


Next, we can merge all the Lines for each episode. But first! Let’s create another Snapshot. Note that at any time, you can download all your snapshots as a single .ZIP. Now, on to merging.


Merge combines nodes of a single category or the edges of a single relationship based on a property value. Here, we’ve combined all the lines spoken on a single episode into a single node based on seasonEpisode


This simplifies the graph considerably, but we can take it a step further. In Module 6. Shortcut, we’ll return to the Snapshot we created before merging, and reduce the graph even more.

Next Steps…