A graph in java?

Hello,
I have a file that represent a graph I suppose:
nodeA    1111  2222
nodeb    2222  4444
nodec    3333  nodeA
noded   nodec nodeaI need for each NodeX to print out all leafs
eg:
nodea 1111 2222
Noded: 3333 1111 2222
what do you suggest? is it better create a representation of the grapgh before? is there any famous solution?
thanks,
Edited by: mickey0 on May 19, 2009 3:39 AM

I would suggest that you first create the graph like this:
import java.util.*;
class TreeMap{
   public static void main(String args[]){
//Create your tree map
TreeMap tm = new TreeMap();
//Fill your map
tm.put(new int(1111), new int(2222));
tm.put(new int(2222), new int(4444));Then, you get an iterator to traverse through the map as you wish (append to the above code):
//Get a set of the entries
Set set = tm.entrySet();
//Get an iterator
Iterator i = set.iterator();
//Proceed with what you want to do with the iterator whether to traverse the content of the map or display all its elements.I hope this makes it clear

Similar Messages

  • How do I generate a graph in Java?

    I need to implement a graph in java or possibly create a graph in excel through java (if possible). any help would be greatly appreciated as i need to do this within about a week!

    Download JFreeChart and give it a try:
    http://www.object-refinery.com/jfreechart/index.html
    JFreeChart is distributed for free, including the complete source code (subject to the GNU LGPL).
    Regards,
    Dave Gilbert
    JFreeChart Project Leader

  • Flexible graphs from java script

    Hi,
    Can anybody help me to find flexible graphs with java script?. I am using Oracle 9i as my database, jsp and ejbs...
    Thank you.

    Can anybody help me to find flexible graphs with java script?. "Flexible graphs"? If you mean a graphing package in Java, just google for it. Plenty of commercial, shareware and freeware choices available (though some are obviously a lot better than others :-).

  • Line graphs in java

    I am looking for a free class that will allow me to graph a line graph in java. I was going to write my own but figured there must already be some out there... There doesn't happen to be a JGraph object that sun is working is there?

    Look at JFreeChart, it contains tools to draw many different charts and graphs.
    DB

  • [Graphs in Java] Graphs library

    Hi there,
    my name is roberto...i want to know if exists a library to construct a graph in java....
    please answer me .. tks

    Sorry--I guess I misinterpreted "graphs".
    Tried googling (neural net java):
    First hit:
    http://rfhs8012.fh-regensburg.de/~saj39122/jfroehl/diplom/e-index.html
    Lots (418,000) of other hits, too. Probably one of them will suit your purposes.

  • Creating control flow graph in java using list

    i am making control flow graph in java by making use of stacks and list but i am unable to get to previous nodes of the current node.
    how to code for the same and make a graph that is randomly generated.

    Don't double post. I've removed the thread you started in the Java Desktop Application forum 4 minutes after this one, with the identically same question.
    db

  • Help||||||||how to draw graphs in java

    dear all
    i m new to the java technology.i am at present working on aproject in which i need to draw graphs.these graphs will show the graphs for past one month,past six month and past one year records display.can u suuggest me where to get the help and how to get the sample sorce code for that.thanx
    regards
    sheetal

    There are a couple of Open Source projects for graphing in Java on Sourceforge, try:
    http://sourceforge.net/projects/jopenchart/
    http://sourceforge.net/projects/jfreechart/
    I haven't used them myself, but I intend to look closer in the future...

  • How to draw a directed 2D graph in java

    how to draw a directed 2D graph in java?-if anybody can suggest some tutorials about this topic or can suggest the way to draw the graph.......how can i do that.......if the nodes of the graph has X and Y co-ordinate.........and the neighbours of each node are known.......suppose
    node1 has neighboures node2,node3 and node4.....node2 has node5 and node3 as neighbours.....in this way....so directed edge from node1 to node2,node3,and node4......
    or if u can suggest other way out......plz reply....

    prometheuzz wrote:
    JosAH wrote:
    If you can draw a line between two points (x,y) and (x',y') you can draw an edge.
    If you can draw one edge you can draw all edges of a graph.Proof by induction!
    ; )Yep, I copied/pasted exactly the same answer I gave this poster in another forum; I recognized him by his 'plz'-es and the abundance of punctuation ;-)
    kind regards,
    Jos

  • Making a graph in java

    Hi
    I want to take data from a mySQL database and show it in an applet as a graph.
    The problem I'm having is creating the graph.
    Does anyone know a fairly simple way to do this?
    thanks

    this can get you started:
    go and google for "applet drawing java source code"
    then when you figure out how they draw in the applet, you can draw some lines and points

  • Graphs in java swing

    hi,
    i am having some x and y values (or some function of x)and i would like to plot a graph between them.
    what is the best and simplest way to do it in java swing.
    thanx

    ...if you want to leave it simple, overwrite a custom JComponent's paintcomponent(Graphics) method and use the native drawing commands such as drawLine(...) and draw(Shape) (take a look at Graphics2D). If you are looking for a more sophisticated solution with professional graph packages i recommend JFreeChart (http://www.jfree.org). It is, however, a bit tricky to use, not suitable if you just begun working with java.

  • Create the graph using java applet

    Hi friends,
    I have one urgent requirement.I need to create the flowchart by using java code.I have data in database.based on that i need to create the parent child relationchip graph..plase anybody help me .
    Thanks&Regards,
    Yousuf alam.A

    malcolmmc wrote:
    JFreeChart has been the favourite Java graph drawing library but, last time I looked, it didn't do flowcharts. If I were you I'd fire up Google and hunt around for a 3rd party library that does. Of course it's a pain if you have to use such libraries in an Applet. It's generally better to generate an image file on a server and display it as part of your html page.Sorry Malcolm but I don't think JFreeChart is applicable. The OP is asking for Flowcharts which are a graph as in nodes and edges. JGraph (Google) is probably what the OP wants but he is in for a shock when it comes to using it.

  • Graphs in Java

    Hi
    I am trying to display some information in graphs..I Have searched some sites. they are giving all the examples in Applets. I dont want to display in Applets I want to display in the HTML page. can any one tell me in which site the examples are there without using applets or give some information regarding this..
    bye
    sanju

    You mean like you have an HTML page with
    <img src="somegraph.gif">
    and somegraph.gif is dynamically generated?
    You'll need to write a "somegraph.gif" servlet that
    - creates an in-memory Image object
    - draws to it using Java2D
    - converts the Image to a gif (or whatever) and writes it out
    Doing this is not trivial, but it can be done.
    You'll need a recent (1.4; I have mixed experiences with 1.3) Java, start your web server with "headless graphics" mode (search the web and the Java forums for it) and write the servlet. Also get a GIF encoder from the web or use the PNG format. I vaguely remember that a GIF encoder doesn't come with the JDK (issues with a recently expired patent). PNG is not supported by some (really) old browsers.
    Search the web for things like
    servlet generate gif
    servlet generate image
    servlet java2d
    E.g. http://www.javasource.org/GifServlet/source/GifServlet.txt is one example (if you use that as an example, try to get rid of the "Frame" object).
    Good luck on your mission, should you choose to accept it...
    (Hey Sun, if you are listening: this might be a nice subject for a tutorial. Pointers to configuring headless mode on popular web servers etc. And now that the gif patent has expired, put a gif encoder in Java2D? Make it easy and "supported" to do Java2D in servlets.)

  • Grid Graph in java

    Is there a tool or a plug in in java that can create a grid graph with X Y cordinates?

    Java3D project provides several objects for graphing:
    https://java3d.dev.java.net/
    http://java.sys-con.com/read/216381.htm
    You may also want to check out NetBeans Graph Library: http://graph.netbeans.org/10/
    JFreeChart library: http://www.jfree.org/jfreechart/

  • Creating graphs with Java

    Hi,
    I want to display the data in a reprot in graphical form using bar graph.
    Can anybody suggest me of any free third party tools that creates graphs (bar/pie graphs etc).

    Google for: java graph
    Here is one worth looking at:
    http://www.jfree.org/jfreechart/index.php

  • Drawing a Dynamic Graph Using Java/J2EE Technology

    Dear Friends,
    I have a immediate requirement.
    I have to draw a dynamic graph based on changing statistical data(Stock market appliaction).
    Have a look at finance.yahoo.com.There we can a find a dynamic graph.The x and y axis in the graph will change according to the data it recieves without using refresh option and all ... In a periodic interval of time ,say for every 10 minutes the application have to check whether it has any changes in the statistical data it recieves (the data maybe from database or form anyother application). If it finds any changes ,automatically it should reflect those changes in the graph.
    Please help me out friends . I have been struggling with this over a period of time but am not able to resolve.
    Please provide me with any sample application and code.
    Keeping my fingers crossed.
    Thanks in Advance.

    I don't have example code, but I am sure JFree.org has lots. It's a free chart API for Java, that also works with Servlets etc.

Maybe you are looking for