Visual Pattern Examples

Visual Pattern Examples

You have learnt all the basic concepts of Visual Query Builder in the previous article. In this article we will walk you through building several visual patterns step by step, and then show you more graph analytics questions and how to solve them with visual patterns.‌

Example 1. Find all the departments with male employees‌.

In the config panel, change the vertex type to be department, and put it in result:

Expand the Filter section in the config panel:

Edit the filter to be (gender == "male"):

Confirm the change:

Then click department vertex pattern in the working panel to create an edge pattern between the two vertex patterns:

In the config panel, change the edge type to be work_in:

Apply the change, and drag the person vertex pattern to a better position:

Example 2. Find all such people A, B, C: A and B are friends, A and C are friends, and B manages C.

Create a new visual pattern named FriendsManagerABC.

An edge pattern is added into the working panel:

Adjust the vertex patterns' positions:

Then, merge the top two vertex patterns:

Then, merge the right two vertex patterns:

Now you have a triangle visual pattern representing the three people relationship!

Example 3. Find the top 2 cities where the most number of companies of an industry are located in.

Change the vertices to be from parameter, and give a parameter name ind. This annotates the industry as an input vertex set when running the pattern:

Confirm the change, and notice there is an id condition on the industry vertex pattern:

Confirm the change, and the label of company vertex pattern becomes company as C:

Expand the Aggregation section in the config panel, and add an aggregation:

Confirm the change:

Expand the Order section in the config panel, and add a descending order of aggregation result countCompany:

Confirm the change:

Expand the Limit section in the config panel, check the use limit checkbox, and change limit to 2:

Confirm the change:

Change the industry vertex id to be "internet", and run the pattern again:

Again, you can choose to output everything in the matched subgraphs:

Example 4. Find the people who either were born in Redwood City or attended Stanford university, but didn't work for Hooli.

Expand Graph patterns section in the pattern list panel, then create a new visual pattern named SearchPeople. Create the following visual pattern following similar steps as above:

Click the left two person vertex patterns respectively to add the union widget:

Click the output person vertex pattern of the union widget, then click the right person vertex pattern, a subtract widget is added into the visual pattern:

Put the output person vertex pattern of the subtract widget into result:

Save and run the pattern:

Example 5. Find all the people that were born in a city with population no more than 100,000, worked for Graphlet, and have research skill.

A snowflake-like visual pattern is commonly used in this type of searching problems:

Example 6. Giving a person P, among all his direct friends and friends' friends who have programming skill, what are the top 5 other skills that most of these people have?

First, we get the friends and friends' friends of P. We use the programming skill to filter these friends, then we find the other skills that these people have. Then we count the number of people having these skills, and choose the top 5 skills as the result.

Last updated