Note in Advance: This is for a personal project, it is not homework related.
Basically I need a java class which will take a 2-d array of numbers
and output a java graphics component with a graph drawn representing
the nodes and vertexes. The class should also colour the vertexes
different colours depending on the value of the number for that
position.
To clarify:
a b c d e
a- 1 0 1 2
b1 - 1 1 0
c1 0 - 1 2
d0 1 2 - 1
e1 1 1 1 -
So if a (top row) and e (side) was 1 you might colour it red, if it
was 0 you might colour it blue (the actual colours arent important but
commenting would be appreciated so I can modify as necessary).
Finally the links between nodes should be uni-directional (That is
they should ideally contain arrows (a double headed arrow for a vertex
thats bi-directional).
I know this is relatively trivial but I need it to support up to 400
nodes and around 20,000 vertexes maximum and I cant find a suitable
algorithm for drawing it nicely....
Feel free to query if you want clarification, I could accept a
solution less perfect (needs to be able to draw 100 nodes minimum and
support 1000 vertexes minimum) but more would be better. |
Clarification of Question by
michael248-ga
on
29 Sep 2006 15:29 PDT
Something which just occured to me (it would be ideal if each node was
created as a sub-component so I can add MouseOver, MouseAction events
etc).
|
Clarification of Question by
michael248-ga
on
29 Sep 2006 15:40 PDT
Incidentally the solution can be part of a library if necessary - im a
competent java programmer (I just struggle with graphics) also it
doesnt matter if the solution calls an external application with the
provision that the external application must be free for individual
use.
|
Clarification of Question by
michael248-ga
on
01 Oct 2006 11:01 PDT
Ok, since this doesnt seem to have received a lot of interest as is, I
would be willing to accept an answer with a link to an algorithm in
java and I will handle the drawing myself.
Please ask for clarification before submitting the answer so we can
agree on whats necessary.
|
Clarification of Question by
michael248-ga
on
05 Oct 2006 07:48 PDT
Ok you have it pretty much spot on, I see your point about the
arrowheads so would happily dump that as an idea (and therefore you
could assume the adjacency matrix was symmetrical but the lines would
still need to be coloured differently depending on value).
I'll add a picture in a little bit and to get someone interested i've
increased the question value to $200.00
|
Clarification of Question by
michael248-ga
on
05 Oct 2006 07:55 PDT
Just to clarify because I think some people may be heading along the
right lines: Its important that the algorithm outputs a nice looking
graph in the sense that as few vertixes as possible should cross over
(this is the part I have problems with).
|
Clarification of Question by
michael248-ga
on
05 Oct 2006 08:03 PDT
Ok since I have increased the price to $200 the drawing part of the
task is mandatory - that is, the algorithm with a java implementation
will be all that is accepted - use of libraries is still acceptable.
|
Request for Question Clarification by
theta-ga
on
05 Oct 2006 08:37 PDT
Hi michael248-ga,
I have started work on a sample app to meet your requirements. I
just needed some clarifications and further information from you:
- Is having each node as a sub-component so that we can add
MouseOver, MouseAction events a hard requirement? This may turn out to
be way more complicated than necessary, and with 20000 vertices and
400 nodes on screen, I doubt that it would be really useful.
- I am planning on utilising an external library for this task
and providing the output graph as a JPanel. Would that be ok?
Thanks,
Theta-ga
:)
|
Clarification of Question by
michael248-ga
on
05 Oct 2006 09:40 PDT
Having the nodes as separate components is a hard requirement - I
appreciate that when theres a lot of nodes the usefulness of it will
diminish but initially the graph will only be representing (say 20
nodes) and being able to access information by clicking on the nodes
will be important....
Outputting as a Jpanel and using an external library is fine - please
make sure the library is free for personal use and the source files
for the library will be required so I can make modifications as
necessary.
|
Request for Question Clarification by
theta-ga
on
05 Oct 2006 21:31 PDT
Hi michael248-ga,
I'll try to get an initial sample app up and running over the
weekend, and then we can take it from there.
Is their a particular collection or data structure you intend to use
to provide the input data?
Regards,
Theta-ga
|
Clarification of Question by
michael248-ga
on
06 Oct 2006 00:42 PDT
Hey
I just planned to use a 2 dimensional int array - so int[x][y], if you
would prefer someother data collection then let me know and i'll use
that instead - pretty indifferent either way.... Thanks :)
|
Request for Question Clarification by
theta-ga
on
06 Oct 2006 01:44 PDT
I just wanted to know if you would be using a particular data
structure to pass in the vertices names or colors with the connection
data (for e.g., which colors do the numbers 0 and 1 signify)?
Also, from the sample connection grid you have provided, it would
appear that all the vertices are *always* connected to each other. If
this is not the case, then we could use the number 0 to indicate no
connection, and the other numbers to denote a connection and the
color.
Another point is that the grid would actually specify the color of the
edge connecting two vertices. So how will the color of the actual
vertex be decided?
Thanks,
Theta-ga
:)
|
Clarification of Question by
michael248-ga
on
06 Oct 2006 02:49 PDT
These are all good points.
Initially I wasnt intending to change the colour of the nodes but this
could be very useful. I think I'll create a data class which will have
the name of the vertex, the colour of the node (as a coded 0,1,2,3 etc
- set these colours to whatever you want and I can change them), and
then inside this data class will be an int array with the connection
values to other nodes (again 0 will be no connection, 1,2,3, etc
various colours - set them to whatever you want).
I'll put the data class I intend to use up in a couple of hours and
I'll send all the data as an array of these objects.
Hope this doesnt complicate things too much.
|
Clarification of Question by
michael248-ga
on
06 Oct 2006 13:43 PDT
theta - just done some searching and think this software would be
perfect (im still willing to pay for a nice java integration, however
if your code is adequate by itself then please feel free to ignore):
http://www.aisee.com
|
Request for Question Clarification by
theta-ga
on
09 Oct 2006 13:55 PDT
Hi michael248-ga,
I was planning to use the Java Universal Network/Graph Framework
(JUNG) for the task at hand. It is a free, open source library, that
supports creating large graphs, multiple configurable layout
algorithms, and (with some effort) mouse events for the edges and
vertices. In short, I think it will meet all your current
requirements. [see http://jung.sourceforge.net/ ]
If you still want me to explore the use of aiSee with the view of
integrating it with java, I will be glad to do so.
Regards,
Theta-ga
:)
|
Clarification of Question by
michael248-ga
on
10 Oct 2006 08:26 PDT
If your happy with it then im happy with it. :)
|
Clarification of Question by
michael248-ga
on
23 Oct 2006 02:22 PDT
theta-ga: just wondered how this was coming along? Its not immediately
pressing but theres been no action for the past 10 days and just
wondering if your still working on it?
|
Request for Question Clarification by
theta-ga
on
24 Oct 2006 17:42 PDT
Hi michael248-ga,
I was shifting houses last week, and so could not devote any time to
this. I'm working on it now, and plan to post the final code by
tomorrow. Given below are the assumptions and feature requests I am
working with, based on your previous clarifications and comments:
- Code compatibility: J2SE 1.4
- Vertices and Edges will be coloured
- Edge arrows are not required/do not matter
- I have created a data class that encapsulates all the information
required for one vertex(name, color and array of edges). A list of
this vertex data class objects is provided whenever a graph needs to
be created.
- Notification of mouse events for the graph.
Regards,
Theta-ga
:)
|
Clarification of Question by
michael248-ga
on
25 Oct 2006 01:03 PDT
Yup thats all fine.
Michael
|