does Java have graphs as an intergrated data structure? How about Python?

I was assigned to write a program, that solves the TSP (travelling salesman problem) via the GRASP (greedy randomized adaptive search procedure). I'm just familiarizing myself with GRASP, and I would like to have a good working data structure for graphs, that includes plotting the graph and the option to assign special colour to edges (so I can colour the final solution: cheapest hamiltonian path).

I'm gonna have a presentation, explaining my final solution, whence the need for plotting the graph. Also, it would be desirable to have the option to generate a random graph on n vertices, so I have some easily accessible examples.

I was really hoping this has been done by someone before, so I don't start from scratch. I'm a mathematician (or atleast trying to be), so please, no fancy programmer slang.

thank you


1 Answer 1


For python.



also check out graphviz.org.

you generate a text file, feed it to graphviz, and it makes a graph as png, pdf, etc.

  • 1
    +1. Also re graphviz: take a look at pydot, which allows you to build the graph directly in python then render via graphviz. Also take a look at python-graph (code.google.com/p/python-graph) for graph algorithms & rendering via graphviz. hth.
    – sfinnie
    Apr 28, 2011 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.