Quantcast

Searching a node based on some attributes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Searching a node based on some attributes

Atreyee Maiti
Hi,

I was wondering if there is a way to find a node given certain attributes in a graph using Jgrapht. I understand that I could always construct a similar node and as long as the equals method is correctly implemented, I would be able to verify if the node exists in the graph but what if I know only 1 specific attribute of the node that I want to search by?

Essentially I am looking for a search filter kind of querying mechanism.

Regards,
Atreyee

------------------------------------------------------------------------------

_______________________________________________
jgrapht-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgrapht-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Searching a node based on some attributes

Szabolcs Besenyei
​If I understand your question correctly, you simply want to filter the vertex set of your graph by a certain attribute.
Let's say we have a relationship graph between people:
UndirectedGraph<Person, DefaultEdge> graph = createRealtionshipGraph();​
You can filter the vertex set simply by:
Set<Person> filteredVertices = new HashSet<>();
filteredVertices.addAll(graph.vertexSet().stream().filter(p -> p.height() > 180));
​(The Person​ class could hold different attributes age, height, sex, etc.)
From here you can create a new graph based on your result or just do something with these vertices.​

I hope I could help.

​Regards,

Besenyei Szabolcs

2015-11-15 8:08 GMT+01:00 Atreyee Maiti <[hidden email]>:
Hi,

I was wondering if there is a way to find a node given certain attributes in a graph using Jgrapht. I understand that I could always construct a similar node and as long as the equals method is correctly implemented, I would be able to verify if the node exists in the graph but what if I know only 1 specific attribute of the node that I want to search by?

Essentially I am looking for a search filter kind of querying mechanism.

Regards,
Atreyee

------------------------------------------------------------------------------

_______________________________________________
jgrapht-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgrapht-users



------------------------------------------------------------------------------

_______________________________________________
jgrapht-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgrapht-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Searching a node based on some attributes

Atreyee Maiti
Thanks for your reply. However, my in-memory graph is large. I don't want to incur the cost of traversing the entire graph. Instead if there is some indexing mechanism or id to quickly fetch some node, that is what I am looking for. Is there any way to do this in jgrapht explicitly?

Regards,
Atreyee

On Sun, Nov 15, 2015 at 2:48 PM, Szabolcs Besenyei <[hidden email]> wrote:
​If I understand your question correctly, you simply want to filter the vertex set of your graph by a certain attribute.
Let's say we have a relationship graph between people:
UndirectedGraph<Person, DefaultEdge> graph = createRealtionshipGraph();​
You can filter the vertex set simply by:
Set<Person> filteredVertices = new HashSet<>();
filteredVertices.addAll(graph.vertexSet().stream().filter(p -> p.height() > 180));
​(The Person​ class could hold different attributes age, height, sex, etc.)
From here you can create a new graph based on your result or just do something with these vertices.​

I hope I could help.

​Regards,

Besenyei Szabolcs

2015-11-15 8:08 GMT+01:00 Atreyee Maiti <[hidden email]>:
Hi,

I was wondering if there is a way to find a node given certain attributes in a graph using Jgrapht. I understand that I could always construct a similar node and as long as the equals method is correctly implemented, I would be able to verify if the node exists in the graph but what if I know only 1 specific attribute of the node that I want to search by?

Essentially I am looking for a search filter kind of querying mechanism.

Regards,
Atreyee

------------------------------------------------------------------------------

_______________________________________________
jgrapht-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgrapht-users




------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
jgrapht-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgrapht-users
Loading...