Filtering nodes based on...

Visual manipulations and refinements
Post Reply
Lurtzello
Posts: 2
Joined: 13 Apr 2017 15:16

Filtering nodes based on...

Post by Lurtzello » 13 Apr 2017 15:48

Hello everyone.
I can't think of an abstract way of explaining what I'm trying to do (other than it has to do with filtering) so I will use an example.

Suppose to have 6 nodes (N1, N2, N3, N4, N5, N6).
N1, N2 and N3 have only incoming edges.
N4, N5 and N6 have only outgoing edges.
Every node has the attribute "Color";
Color(N1,N2)="blue";
Color(N3)="red";
Color(N4,N5,N6)="null".
I want to hide the nodes with outgoing edges that are linked 'to just one color' (just to "blue" or just to "red"). Therefore:
N1, N2, N3 are always shown.
N4 is connected to N1; N4 is hidden.
N5 is connected to N1 and N2; N5 is hidden.
N6 is connected to N1 and N3; N6 is shown.

Do you know if such a filter is feasible?

User avatar
eduramiba
Gephi Code Manager
Posts: 920
Joined: 22 Mar 2010 15:30
Location: Madrid, Spain

Re: Filtering nodes based on...

Post by eduramiba » 13 Apr 2017 16:02

Hi,
I can't think of any way how to do this with the available filters.
Maybe you can script this conditions with the scripting plugin and create a column which you can filter on: https://github.com/gephi/gephi/wiki/Scripting-Plugin

Lurtzello
Posts: 2
Joined: 13 Apr 2017 15:16

Re: Filtering nodes based on...

Post by Lurtzello » 27 Apr 2017 23:14

eduramiba wrote:
13 Apr 2017 16:02
Hi,
I can't think of any way how to do this with the available filters.
Maybe you can script this conditions with the scripting plugin and create a column which you can filter on: https://github.com/gephi/gephi/wiki/Scripting-Plugin
Thank you for the very quick answer!
Alas, I also posted my question on the Facebook Gephi group and ended up forgetting about the forum.
There, I was suggested to use a programming language to generate a new attribute offline (out of Gephi) and I see from your suggestion that you intended for the same thing - just 'in Gephi' rather than 'out of it'.

Since I'm a bit rusty with my programming, though, I decided to look for alternative solutions and came up with this (copy-pasting my answer from the Facebook group):

What I ended up doing was exporting the Edges table as a CSV and using Excel to edit it. I had a Source column (A), a Target colum (B), and a Color column (C, Color is a function of Target).
I then sorted by Source and added a Keep column (D) in which I entered this formula: =OR(IF(A1=A2;IF(C1=C2;0;1);0);IF(A2=A3;IF(C2=C3;0;1);0)). The formula returns TRUE if the adjacent records have the same source but different color.
I then filtered by Keep=TRUE, copy-pasted the Source and Keep columns to another CSV file and imported that as a nodes table to Gephi, which simply added a Keep column in its data laboratory and gave the value TRUE to the nodes that matched those in the imported spreadsheet.
At this point I simply had to filter based on the value of the Keep attribute (to include all Source nodes of interest) and based on the In Degree Rage (setting it greater than 0, to include all Target nodes) to go from a graph of 222491 nodes and 331560 edges to one of 3852 nodes and 13496 edges!

Post Reply