Re: [jgrapht-users] Searching a node based on some attributes
Brought to you by:
barak_naveh,
perfecthash
From: Szabolcs B. <bes...@gm...> - 2015-11-15 22:48:25
|
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 > > |