views:

106

answers:

7

Is there a public library for Java (free) that can be used to display graphs (I am talking about discrete graphs - not bar charts, pie charts, etc...)?

+4  A: 

There's an open source version of JGraph.

Bart Kiers
A: 

If using Google's Chart API is an option, check out Charts4J.

I use it and have had no problems.

Coronatus
If I assume that "mathematical graphs" means x-y plots of typical functions, JFreeChart can create those. I know a lot of math, both continuous and discrete, and I know what it is to be discrete, but I'm not sure that I know what "discrete, mathematical kind" means. And "manager graphs"? C'mon.
duffymo
@Duffy, by discrete I meant 'discrete math'. And I put a smiley behind by remark. IMO, you're being pedantic right now.
Bart Kiers
"Discrete math" would have been far more correct than "discrete, math". It's not pedantic - go read "Eats, Shoots, and Leaves". Your "smilely" came after "manager graphs.
duffymo
@Duffy, The pedantic remark was about your comment: *"And "manager graphs"? C'mon."*
Bart Kiers
I'm saying that your division into categories is arbitrary and incorrect.
duffymo
@Duffy, yes I agree with you on that (hence the removal of my first remark).
Bart Kiers
+3  A: 

JFreeChart is good.

And if laying out graphs is what you're after, I'd recommend AT&T's graphviz as an alternative. Give it the data and it lays out the graph for you.

duffymo
Dyffy, that's the type the OP *didn't* need.
Bart Kiers
@Bart K., I don't think you really know what the OP needs. It's not well stated at all.
duffymo
@duffy, true, I am (or was, now that my answer is the accepted one) not 100% sure but the comment of the OP that s/he didn't want bar- or pie charts, seemed to me clear that the mathematical kind of graphs were meant. Don't you agree?
Bart Kiers
No, I do not. Your answer might have been accepted, but that doesn't mean that the OP knows what they're doing or that you're correct. Bar or pie charts can certainly represent mathematical concepts when appropriate, so your partitioning into "manager" and "mathematical" charts is arbitrary and wrong. And neither you nor the OP has been specific about exactly what "mathematical" graphs are. Don't tell us what they're not.
duffymo
Okay, then we disagree on that. I clarified my "loose terminology" already in the other comment. But take it easy, I didn't mean to offend you (which it seems to me you are a bit. Of course, I could be wrong about that: hard to tell on forums).
Bart Kiers
+1  A: 

JFreeChart. The code is free. You have to pay for the authors docs, but there are plenty of examples around and it's pretty easy to learn to use.

Joel
Hmm. Maybe I'm wrong but am pretty sure JFree can do things like this: http://www.mathworks.com/help/techdoc/creating_plots/f10-1188.html Maybe the OP should post a link to an example
Joel
AFAIK, the op meant these graphs: http://en.wikipedia.org/wiki/Graph_theory
Bart Kiers
+3  A: 

The JUNG (Java Universal Network/Graph Framework) framework allows you to sample their various graphing layouts online. Here is a screen shot of the ShowLayouts2 demo:

A screen shot of a JUNG example

Adam Paynter
A: 

Sorry, I misunderstood the question. The thing you are looking for is called JUNG - the Java universal network/graph library. It can store, display and calculate various metrics on sparse or dense graphs. The official site has excellent samples.

Quote from the website above:

"The JUNG architecture is designed to support a variety of representations of entities and their relations, such as directed and undirected graphs, multi-modal graphs, graphs with parallel edges, and hypergraphs. It provides a mechanism for annotating graphs, entities, and relations with metadata. This facilitates the creation of analytic tools for complex data sets that can examine the relations between entities as well as the metadata attached to each entity and relation."

reseter
How is this new information? And if that's the case, graphviz might be another choice.
duffymo
A: 

There is a Graphviz library for Java at http://www2.research.att.com/~john/Grappa/. I have used Graphviz for a project in the past to draw graphs and I found it quite easy to use. If you are just looking for a server side solution, then you could just use a standard Graphviz distribution and send it the commands with the "dot" syntax that it uses.

Clay Horste