Quantcast

jgrapht - Find all the nodes that are at most x units away from a particular node

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

jgrapht - Find all the nodes that are at most x units away from a particular node

Sandeep Sas
Hi,

I am pretty new to jgrapht. 

I am looking for a solution to find all nodes, which are less than x units away from a particular graph node. I am using jgrapht's  DefaultDirectedWeightedGraph. 

Is there any easy way to perform this using jgrapht library?

Thank you
Sandeep

DefaultDirectedWeightedGraph <GraphNode,DefaultWeightedEdge> graph = new  
            DefaultDirectedWeightedGraph <GraphNode,DefaultWeightedEdge>(DefaultWeightedEdge.class);

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
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: jgrapht - Find all the nodes that are at most x units away from a particular node

Szabolcs Besenyei
A possible one-liner off the top of my head:
FloydWarshallShortestPaths fwsp = new FloydWarshallShortestPaths(graph);
fwsp.getShortestPath(sourceVertex).stream().filter(path -> path.getWeight() <= MAX_DISTANCE).collect(Collectors.toList());

Üdvözlettel,

Besenyei Szabolcs

2015-12-05 17:50 GMT+01:00 Sandeep Sas <[hidden email]>:
Hi,

I am pretty new to jgrapht. 

I am looking for a solution to find all nodes, which are less than x units away from a particular graph node. I am using jgrapht's  DefaultDirectedWeightedGraph. 

Is there any easy way to perform this using jgrapht library?

Thank you
Sandeep

DefaultDirectedWeightedGraph <GraphNode,DefaultWeightedEdge> graph = new  
            DefaultDirectedWeightedGraph <GraphNode,DefaultWeightedEdge>(DefaultWeightedEdge.class);

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
jgrapht-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgrapht-users



------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
jgrapht-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jgrapht-users
Loading...