In this Session…
Before you begin…
To follow along, download the ﬁles:
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:
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.
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 ﬁnd 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 ﬁrst! 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 simpliﬁes 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.
How To GraphXR: Module 6. Shortcut.