JGAlgo

What is the JGAlgo Library?

The Java Graph Algorithm library is a high-performance library for graph algorithms written in Java. It contains a wide collection of optimized algorithms and data structures for a range of problems on graphs. From calculating shortest paths and maximum flows to computing minimum spanning trees, maximum matchings, vertex covers, and minimum coloring.

The library runs on Java 11 or higher, and it is installed using Maven.

Quick Start

Add jgalgo-core as a dependency to your project pom.xml:

<dependency>

<groupId>com.jgalgo</groupId>

<artifactId>jgalgo-core</artifactId>

<version>0.5.0</version>

</dependency>

Algorithms

JGAlgo library offers a diverse collection of graph algorithms that operate on a Graph object as input. From finding the shortest paths and maximum flows to computing minimum spanning trees, vertex covers, and cycle detection, the library provides a comprehensive set of optimized algorithms solving these problems.

Shortest Path

The Shortest Path family of algorithms deals with finding the shortest paths between vertices in a graph, where 'shortest' is defined with respect to a weight function that assign a real value to each edge, and the 'length' (or 'weight') of a path is its edge weights sum. Multiple variants are implemented, such as single source (SSSP), all pairs (APSP), S-T, K shortest paths between S-T, Voronoi cells, Chinese postman problem, TSP, ect.
[javadoc]

Matching

Matching is a set of edges without common vertices. Algorithms that find a matching with maximum/minimum edges/weight are available.
[javadoc] 

Flow

Flow network is mapping of each directed edge in a graph to capacity and flow amount values. The amount of flow on an edge cannot exceed the capacity of the edge. An amount of flows along edges entering a vertex should be equal to the amount of flows along edges exiting it, except special vertices such as source and sink. There is also definition for undirected graphs used in the library.
[javadoc]

Minimum Spanning Tree (MST)

The Minimum Spanning Tree algorithms find the spanning tree (edges subset that maintain the connectivity of the graph) with the minimum weight with respect to a given edge weight function. Both  undirected and directed graphs are supported.
[javadoc]

Connectivity and Cuts

The connectivity of a graph is the ability of reaching from one vertex to another use the (maybe directed) edges of the graph. Available algorithms include strongly/weakly connected components, bi-connected components, k-vertex/edge connected components, min global/local(S-T) vertex/edge cut.
[javadoc]

Isomorphism

Given two graphs, an isomorphic mapping is a mapping between the vertices of the two graphs while preserving the structure of the graph. There are a few variants of the problem:

All The variants are supported by the library using algorithms like the VF2 algorithm.
[javadoc]

Cores

Given a graph G=(V,E), a subgraph H induced by a subset of vertices W is a k-core if it is the maximum subgraph in which every vertex has a degree of at least k. The core number of vertex is the highest order of a core that contains this vertex. A cores algorithm can compute the core of a specific k, or the core number of the vertices.
[javadoc]

Cliques and Independent Sets

Finds all maximal cliques in an undirected graph using algorithms like the Bron-Kerbosch algorithm. A clique is a set of vertices where every pair of vertices is adjacent, and a maximal clique is a clique that cannot be extended by adding more vertices. Finding all maximal independent sets is also implemented by computing the maximal cliques in the complement graph.
[javadoc]

Coloring

The Coloring family of algorithms is concerned with finding the minimum number of colors needed to color the vertices of an undirected graph such that no adjacent vertices share the same color.
[javadoc]

Graph Traversal

Traversal algorithms are used to explore the vertices and edges of a graph in a systematic way.

Covers

Cycles

Cycles algorithms involves finding cycles in a graph.

Lowest Common Ancestor (LCA)

Given a tree, the least common ancestor of two vertices is the common ancestor of both vertices (contained in the paths from the vertices to the root) and is the furthest from the root (lowest). Multiple variant exists, such as 'offline' where the algorithm receive both the graph and the set of queries in advance, and it is require to answer these queries along, 'static' where the algo preprocess the tree once, and can answer any LCA queries efficient afterwards, and the 'dynamic' that support efficient queries of LCA while allowing adding new leaves to the tree.
[javadoc]

Other

Graphs I/O

The library supports reading and writing graphs from/to files in various formats. The supported formats are:

 License

The JGAlgo library is released under Apache License, Version 2.0.