Re: [jgrapht-users] Searching a node based on some attributes
Brought to you by:
barak_naveh,
perfecthash
From: Atreyee M. <atr...@gm...> - 2015-11-16 08:38:52
|
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 <bes...@gm...> 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 <atr...@gm...>: > >> 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 >> jgr...@li... >> https://lists.sourceforge.net/lists/listinfo/jgrapht-users >> >> > |