r/javahelp • • Apr 11 '20

Which Java library of graph theory data structures and algorithms would you recommend?

I have to perform operations on large graphs (PageRank, DFS,/BFS traversal , etc).
The structural properties are:

  • directed edges: an edge has a source and a target

  • self-loops: whether to allow edges which connect a vertex to itself

  • multiple edges: whether to allow more than one edge between the same vertex pair

  • Both Nodes (Vertex) and Relationsships (Edges) must be able to contain properties.

I don't want to use a graph database such as Neo4J .

I've found JGraphT

Is this a good Java graph library?

Would you recommend others?

17 Upvotes

6 comments sorted by

6

u/aragonSkywalker Apr 11 '20

JUNG looks promising. I used it just for random graph generation but it seems capable for your needs

3

u/lemoussel Apr 11 '20

24 January 2010: JUNG 2.0.1 released. Ten year ago ???

2

u/aragonSkywalker Apr 11 '20

Then I would also use JGraphT :D

2

u/WestCoastTyyppi Apr 11 '20

Yes jgrapht will work well. It can handle multiple edges , loops, directed graphs, etc. You can define your own Edge and Vertex classes to allow you to store whatever you need to in them.

1

u/kyromoto Jun 18 '20

Do u have a clue how I can make a graph out of different entites? I used a abstract class for my different kinds of entites, but I do not know how to access an entity as subclass. Or is there a better way?

0

u/[deleted] Apr 11 '20

[deleted]

2

u/lemoussel Apr 12 '20

I don't need a distributed graph database. And it must work on Raspberry Pi with 2Gb of RAM.