Questions tagged [jgrapht]

JGraphT is a free Java graph library that provides mathematical graph-theory objects and algorithms.

JGraphT supports various types of graphs including:

  • directed and undirected graphs.
  • graphs with weighted / unweighted / labeled or any user-defined edges.
  • various edge multiplicity options, including: simple-graphs, multigraphs, pseudographs.
  • unmodifiable graphs - allow modules to provide "read-only" access to internal graphs.
  • listenable graphs - allow external listeners to track modification events.
  • subgraphs graphs that are auto-updating subgraph views on other graphs.
  • all compositions of above graphs. Although powerful, JGraphT is designed to be simple and type-safe (via Java generics). For example, graph vertices can be of any objects. You can create graphs based on: Strings, URLs, XML documents, etc; you can even create graphs of graphs! This code example shows how.

Other features offered by JGraphT:

  • graph visualization using the JGraph library
  • complete source code included, under the terms of the GNU Lesser General Public License.
  • comprehensive Javadocs.
  • easy extensibility.

Official website: http://jgrapht.org/

303 questions
2
votes
1 answer

How to map jgrapht Graph to another Graph?

I have the following graph: private final Graph graph = buildGraph(); @Override public Graph buildGraph() { return GraphTypeBuilder .directed() …
Manuel Waltschek
  • 515
  • 1
  • 6
  • 23
2
votes
2 answers

jGraphT for Objective C?

I'm looking for a Directed Acyclic Graph implementation in Objective C. I've had enormous success with jGraphT in the Java space. I'm using a DirectedGraph to model a power subsystem, and now I need equivalent code for iPhone/iPad. Does such a…
retrodrone
  • 5,850
  • 9
  • 39
  • 65
2
votes
1 answer

Compute all edge-disjoint paths between two given vertices of a simple directed graph

Many similar questions have been asked, but non addresses exactly my situation: Given two vertices in a simple directed unweighed graph, and an integer k, how can I find all k-tuples of edge-disjoint paths between the vertices? (In particular, I'm…
Sebastian
  • 315
  • 2
  • 12
2
votes
1 answer

POM to import JGraphT nio package

Trying to run the JGraphT hello world example, POM per here looks like: org.jgrapht jgrapht-core 1.4.0 But this is not pulling down the org.jgrapht.nio.* it seems, file tree below:…
shanlodh
  • 1,015
  • 2
  • 11
  • 30
2
votes
1 answer

Building a graph with JGraphT Version 0.8.2 is faster than with Version 1.3.0

Im building a graph with over 90000 edges: DefaultDirectedGraph graph = ... graph.addVertex(keyFrom); graph.addVertex(keyTo); graph.addEdge(keyFrom, keyTo); With new version I have following results: BUILD_GRAPH took 13596 ms Number of edges:…
2
votes
0 answers

Java JGraphX - is there a method to re-position the vertexes and edges automatically?

the title says it all, I'm using the below code to create a PNG image of the graph as you can see that the edges don't look good and the labels on the edges are intersecting/overlapping with each other, is there any way to increase the size of the…
MiRaN
  • 641
  • 1
  • 6
  • 11
2
votes
3 answers

How to find roots and leaves set in jgrapht DirectedAcyclicGraph

My code: import org.jgrapht.graph.DirectedAcyclicGraph; // ... private DirectedAcyclicGraph graph = new DirectedAcyclicGraph<>(DefaultEdge.class); // ... graph.addVertex("x"); graph.addVertex("y"); // ... graph.addEdge("x",…
Mugen
  • 8,301
  • 10
  • 62
  • 140
2
votes
1 answer

Graph traversal for hierarchical relations

I have graph represents the parent child hierarchy. Also it holds the relationship between objects. I have above as graph. Where Orange are my parent-child hierarchy and Green are my relations. So if i want to get relation between E and F, i…
SuhasD
  • 728
  • 2
  • 7
  • 20
2
votes
3 answers

Serializable in Java - JGraphT's Pair class - Should the type of instance members also implement Serializable?

From here, JGraphT's Pair class is Serializable. But the instance members this class contains (first and second) are not forced to be Serializable. This is how the current implementation looks like: public class Pair implements …
Lavish Kothari
  • 2,211
  • 21
  • 29
2
votes
2 answers

Get all vertex in JgraphT

In jgrapht, I have added some vertex. I wanted to know how to get all vertex that I have added or already exist in jgrapht ? Is there a way to get it ?
Anto Livish A
  • 322
  • 4
  • 15
2
votes
0 answers

JGraphT: How can I get minimum edge count between to vertex?

I want to get minimum edge count between to vertex with jgrapht, Not shortest path.But I still have no idea after tried many times;
polunzh
  • 318
  • 2
  • 11
2
votes
1 answer

Can JGraphT java library be used for making 3D graphs

Basically I have to plot a 3D undirected graph from the list of vertices.At present I can plot a undirected graph in 2D and I have used the following code for this. import java.awt.Color; import java.awt.Dimension; import java.awt.Rectangle; import…
2
votes
1 answer

JGraphT: get neighbor nodes

I have a simple undirected graph G = (V, E). Given a node n, is there an easy way to find all its neighbors, i.e. all nodes m, such that {n, m} in E? There's edgesOf method, which returns all edges connected to given node. However, it seems that in…
Jan Pomikálek
  • 1,369
  • 2
  • 13
  • 22
2
votes
0 answers

Getting the shortest number of paths irrelevant of the weight JGraphT

I'm trying to find/create an algorithm to find the least number of edges to traverse to, to get to a vertex. I am using a SimpleDirectedWeightedGraph, but I don't want to use Dijkstra's algorithm because I want to omit the weights doing this. Is…
madcrazydrumma
  • 1,847
  • 3
  • 20
  • 38
2
votes
1 answer

JGraphT - apply BFS to WeightedGraph

I have written the code finding the optimal path for a Weighted Graph: SimpleDirectedWeightedGraph graph = new SimpleDirectedWeightedGraph
TheMP
  • 8,257
  • 9
  • 44
  • 73