how to find if two vertices are connected with Jung Framework? - java

I want to know how to check if two vertices are connected in a graph using Jung Framework.
Thanks.

If the graph is undirected (you haven't specified) or if you don't care about edge direction, use WeakComponentClusterer to split the graph into its (weakly) connected components, and then check to see if the vertices are in the same component. (BicomponentClusterer is not correct for this case if I understood your question correctly.)

Related

GraphStream drawing grouped nodes in graph

I already created graph with different color each graph based on some attribute in its node. This is my current graph
Is it possible to place node that has same color closely? How could I implement that?
I am looking for a similar functionality and came across Viewers (http://graphstream-project.org/doc/Tutorials/Graph-Visualisation_1.0/). I disabled the default viewer and mentioned co-ordinates for individual nodes (which works but doesn't look pretty and is additional headache to mention co-ordinates in the code).
However, I haven't figured out if we can still use default viewer and group nodes based on some attributes.
Let me know if you figure out a way to do that.

Android guiding application

I am creating an Android application in which the user searches for the position of a book in a library.
My issue is with the way I am going to draw the bookshelves and the shortest route that the user is going to follow from his position.
One idea is to implement an a matrix but I don't think it really works so I would like some help if possible.
This is the implementation of the library in paint (the green lines are the routes in a way the user can take to get to the book):
For example, you can create a model of library hall as a graph and search for shortest path from one vertex (current user location) to another (location of book) using Dijkstra's algorithm. Each vertex of graph is a real point in the library hall. Weight of each graph edge is real distance between these points. Algorithm is quite simple to implement and well described in Wikipedia.

how to draw automata in java

i want to draw an automata with edges and circulaire states, something like this http://pop-art.inrialpes.fr/~girault/Cours/Automates/td5.html, have u an example for that
JGraph is a library you can use that is native to Java and fairly easy to use, or you can generate a .dot file and let GraphViz take care of it for you.
If you dont want to carry for things like representing the graph in a correct way such you try to not cross the lines, or to not have two or more nodes in the same position then i suggest you to use grail graph library so you can see the graph using yed works (I can provide you an example of it just write the regular expression you in comment), or if you want to draw the graph by yourself then you probably is good to learn about Layered graph drawing :
http://en.wikipedia.org/wiki/Layered_graph_drawing
and Coffman Graham algorithm
http://en.wikipedia.org/wiki/Coffman%E2%80%93Graham_algorithm

Algorithm for drawing a graph structure?

I have a digraph graph G=(V,E) that I would like to redraw because it is currently very messy. This is a flow chart that is being visualized and since |V|>1000 and each v in V has more than 1 outgoing edge, it is very hard to trace by eye. For instance; a node on the lower left corner is connected by an edge to a node on the upper right corner. It would be better, for example, if these two nodes were placed next to each other. There are too many edges and it is a pain to trace each of them.
I have access to and can change the (x,y) coordinates of all the vertices. I would like to redraw G by maintaining it's current structure, in a way that is more human-friendly. I thought that minimizing the number of intersecting edges may be something to start with.
Is there an algorithm that can help me redraw this graph?
My question is, how do I assign (x,y) coordinates to each v in V such that it is organized better and easier to trace and read? How do I express these requirements formally? Should I go with a heuristic, if this is NP? Here is an example for a somewhat organized graph and this is something messy (although much smaller than what I'm dealing with).
Any help will be greatly appreciated. Thanks.
EDIT: I'm still looking for a to-the-point answer. I've researched into planar straight-line and orthogonal drawing methods but what I've got is lengthy research papers. What I'm seeking is an implementation, pseudo-code or at least something to get me started.
EDIT 2: I'm not trying to display the graph. The input to the algorithm shall be the graph G (composed of V and E) and the output shall be {(xi, yi) for each vi in V}
You want to look at graphviz.org; this is a difficult problem on which there has been a lot of research, reimplementing the wheel is not the right way to go.
Probably you'll have to get the java to write out a datafile which a tool like 'dot' can read and use for the graph layout.
That messy one seems to be drawn using spline, try planar straight line algorithm instead. Indeed this is a very difficult problem and I always use GraphViz as my backend graph drawing tools, you can generate that graph you want with -Gsplines=line option.

How to plot a node in given coordinate using JUNG

I want to virtualize my network simulations and need to plot the nodes in the network. Each node has a pre-defined location and I need to plot the nodes into the correct coordination.
I am using JUNG: http://jung.sourceforge.net/applet/index.html
Any suggestions?
Thanks!
I recently solved this problem by writing my own rendering Layout for JUNG.
As base for my derived layout I used the Circle Layout, which is pretty simple. In there you will see that JUNG does a setLocation(Dimension d) for every Vertex, which is pretty much what you are looking for, I guess. Just take a look at the source of the CircleLayout.
Then you could use a custom Vertex object, which stores the coordinates you want the vertex to have, which is then read by your custom layout.

Categories

Resources