Questions tagged [jgrapht]

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

jgrapht
Filter by
Sorted by
Tagged with
0 votes
1 answer
805 views

JGraphT Good Performance/Storage with Millions of Dynamic Nodes/Edges

I'm trying to find the shortest path in a graph with a million nodes. On average, there are likely 20 directed edges per node, so it's quite sizeable. In addition to this, is there a way to adjust the ...
DFx's user avatar
  • 239
0 votes
1 answer
474 views

how to create a subgraph with jgrapht

I am using jgrapht in Java to work a network-based algorithm. I first read an adjacency list and then create jgrapht based graph. Now, given a subset of nodes called subNodes, I'd like to generate a ...
whitepanda's user avatar
0 votes
1 answer
369 views

How to get max_weight_matching in java

I have a Weighted and Non-Bipartite graph and would like to get the maximum weight matching. I have done the task with the python networkx library and looking for an alternative library for java. I ...
Gevorg Harutyunyan's user avatar
3 votes
0 answers
53 views

JGraphT: Inconsistent graph size for same dataset

Version: 1.3.0 Graph Requirement: Child will have many parents or none. Data Node: Id + List [Parent ids] class Node { String id; List<String> parents; } Total dataset: 3500 nodes. ...
Amit Gupta's user avatar
2 votes
1 answer
601 views

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 ...
Sebastian's user avatar
  • 315
0 votes
0 answers
124 views

Plot only paths up to a certain length in Graphviz

For a graph created in a specialized library like JGraphT, subpath calculations can be made and subgraphs with paths of length up to a maximum value N can be derived prior to visualizing. Is there any ...
PNS's user avatar
  • 19.6k
5 votes
2 answers
4k views

How to do Topological Sort (Dependency Resolution) with Java

Description The purpose of the question is to implement an interface that will order a list of tasks according to the information about their dependencies. For example, if task A has a dependency on ...
Dzikoŭski's user avatar
0 votes
1 answer
1k views

how to create an induced sub graph in JgraphT

Let G=(V,E) be an undirected graph. I'd like to create an induced sub graph for a given subset of nodes U with JgraphT in Java. Here is an adjacency list. 0 1 0 3 1 0 1 2 1 3 2 1 2 3 3 0 3 1 3 2 ...
sergey_208's user avatar
3 votes
1 answer
1k views

POM to import JGraphT nio package

Trying to run the JGraphT hello world example, POM per here looks like: <groupId>org.jgrapht</groupId> <artifactId>jgrapht-core</artifactId> <version>1.4.0</version&...
shanlodh's user avatar
  • 1,035
0 votes
1 answer
382 views

JGraphT - library algorithm to find a path via some specific vertex

I use JGraphT library to work with a quite complex topology. There is a plenty of library algorithms like Dijkstra Shortest Path provided by the library. My question is: I need a way to find a path ...
Software Craftsman's user avatar
0 votes
1 answer
476 views

Import a edgelist graph using its elements as labels with JGraphT 1.4.0 [duplicate]

I updated a project of mine from JGraphT 1.3.1 to 1.4.0 and noticed that a new org.jgrapht.nio package has been introduced for I/O; I thought to switch to it, since basically org.jgrapht.io has been ...
bissim's user avatar
  • 13
1 vote
2 answers
2k views

(JGraphT) Export Graph<String, DefaultEdge> as DOT

I use the jgrapht library and I have directed Graphs with Strings as vertices and DefaultEdges as edges. Now I wonder how to export my graph in the DOT format. What would be the best approach for ...
Pfinnn's user avatar
  • 512
0 votes
1 answer
267 views

Trying to use Kotlin reified type parameters with a library class

I am using JGraphT library from Kotlin and I want to have my graph parametrised. However, the way I was trying to do it does not work, since U is not defined at the compile time and can not be used ...
lsa's user avatar
  • 25
0 votes
0 answers
175 views

JGraphT Failed to Parse Graph

Hi I am new to JGraphT and am trying to import a graph to work with. I have attached a sample below of the graph and the classes i have set up as the vertex and edges. Hopefully i am doing this the ...
docker dev's user avatar
1 vote
0 answers
58 views

How do you model Layover and Travel Duration in a Graph

We are creating a replica of amtrak.com and would like to implement a search algorithm for finding paths between station A and station B. We currently are unable to effectively filter search options ...
Saffat Hasan's user avatar
0 votes
1 answer
251 views

JGraphT: Replacing subtree in a directed acyclic graph by another subtree

Let's assume I have the following two tree graphs: a i / \ / \ b c j k / \ / \ ...
CIOC's user avatar
  • 1,397
0 votes
1 answer
580 views

Using vertex String IDs as the actual vertices while importing graph (jgrapht 1.4)

I have very simple graph strict digraph G { <assembly-raw-file>; <dataset-processing>; <feature-processing-1>; <feature-processing-2>; <mh.permute-variables-and-...
Sergio Lissner's user avatar
0 votes
1 answer
505 views

JGraphT create a random graph from pre existing vertices

I need to create a random graph from a few pre existing vertices. I didn't find a way to do this yet. Each tutorial is using the "VertexFactory" (which btw cannot be resolved even though importing ...
ICEBERG's user avatar
  • 13
2 votes
1 answer
232 views

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:...
Markus Dorn's user avatar
0 votes
1 answer
266 views

How to create a graph with sugraph with jgrapht

I want to create a graph with subgraphs (I think cluster is a synonymous - not sure ?). Someone could explain how to create this type of graph and how to export this composite graph. I readed this ...
jpl's user avatar
  • 382
0 votes
1 answer
368 views

JGraphT implementation in Android

I implemente JGraphT into Android Application. I have added everything needed into Gradle and after that I wanted to put some examples into code: SimpleDirectedWeightedGraph<String, ...
MaciejB's user avatar
  • 76
2 votes
0 answers
847 views

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 ...
MiRaN's user avatar
  • 641
0 votes
2 answers
1k views

Remove node from graph during traversal

I am trying to delete a node/set of nodes from a defined graph (org.jgrapht.Graph) before doing a Topological traversal on it. Sample graph definition Graph<URI, DefaultEdge> g = new ...
Hitesh's user avatar
  • 137
0 votes
1 answer
130 views

Traversing directed graph breadth first with vertexes having longest paths first

Given a directed graph of dependencies, I want to traverse this graph from the root node level by level (that is breadth first) however taking the nodes on each level in a certain order. In my case, ...
Andreas Jakobik's user avatar
1 vote
0 answers
411 views

Is there an implementation of the Lengauer-Tarjan dominator tree algorithm in the Java-based jgrapht graph library?

I am looking for a graph library that provides an implementation of the Lengauer-Tarjan dominator tree algorithm [1] in Java (or any other dominator tree algorithm that performs at least equally well)....
Markus Weninger's user avatar
0 votes
1 answer
477 views

Split a tree in a forset using jgrapht

I have a tree represented with the library jgrapht, there are variuous type of nodes I need to cut any subtree starting from a particulare node type. As you can see in this example, this tree ...
Philip's user avatar
  • 781
0 votes
0 answers
510 views

How to correctly modify vertices in JGraphT?

I built a graph with some vertices. The vertices are of my own class, containing some informations, but not more. Then I traverse the graph, changing these informations if some conditions are met. ...
Flontis's user avatar
  • 327
2 votes
1 answer
1k views

Creating graph with clusters using jgrapht

Is there any way to create a graph with clusters using jgrapht? Example graph with two clusters "process #1" and "process #2": Expected dot file content : digraph G { subgraph cluster_0 { style=...
Edwin's user avatar
  • 23
0 votes
1 answer
686 views

How to check which implementation is used on a List of an Interface

pretty new to Java, I have a Graph of JGraphT with Employees as nodes and an Interface called "FeatureEdge" as edges. I create some edges by reading through a database to connect my employees. Now ...
sav's user avatar
  • 53
0 votes
2 answers
219 views

How to allow negative weights on a Graph in JGraphT?

I have a graph and want to find the LONGEST path from source to sink. My idea was to reverse the weight to negative numbers and run dijkstra on it, as implemented in JGraphT ...
Flontis's user avatar
  • 327
0 votes
0 answers
318 views

How to find all the paths starting from one vertex to an end vertex in a directed graph using jGrapht?

I need to find all the paths starting from one vertex and traverse in a path until that path ends.
Sahan Sandaruwan's user avatar
0 votes
1 answer
1k views

JGraphT: How to use JSONImporter to Import my DirectedMultigraph with Labeled Edges

I have created a custom edge class as defined here. The only change I made was a No Arg constructor in order to get the import code below to run. I have successfully generated a DirectedMultigraph via ...
daniel9x's user avatar
  • 775
0 votes
1 answer
613 views

JGraphT: How to represent set of Vertices and Edges as efficiently as possible

I am new to Graph theory in addition to this JGraphT (Java) library I'm using in order to implement a solution to a logistics issue I'm trying to solve. As such, I'm a little lost on the best way to ...
daniel9x's user avatar
  • 775
2 votes
3 answers
2k views

How to find roots and leaves set in jgrapht DirectedAcyclicGraph

My code: import org.jgrapht.graph.DirectedAcyclicGraph; // ... private DirectedAcyclicGraph<String, DefaultEdge> graph = new DirectedAcyclicGraph<>(DefaultEdge.class); // ... graph....
Mugen's user avatar
  • 8,803
0 votes
1 answer
74 views

Is it possible to use inheritance with JGraph

I have a graph declared as Graph<MyBase, DefaultEdge> myGraph = new DefaultGraph<MyBase, DefaultEdge>(); I want to be able to keep the graph and edges and replace the base class types ...
user_mda's user avatar
  • 18.8k
2 votes
1 answer
788 views

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. ...
SuhasD's user avatar
  • 738
0 votes
0 answers
394 views

How to compile HelloJGraphT demo?

I need to use JgraphT to compile and run this https://jgrapht.org/guide/HelloJGraphT I used command line to create a maven project with jgrapht https://github.com/jgrapht/jgrapht/wiki/How-to-use-...
Paul's user avatar
  • 1
2 votes
3 answers
669 views

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: ...
Lavish Kothari's user avatar
0 votes
2 answers
518 views

How can I create multiple edges with the same weight and same source vertex?

I'm using jgrapht and I'm having a problem here. As soon as I create two edges with the same weight from one source vertex, I end up having just one edge: DirectedWeightedPseudograph<Object, ...
AMine Bendriss's user avatar
0 votes
1 answer
223 views

Do the function “GetDiameter” in JGraphT cost much internal memory?

Here is the problem: Recently I would like to use JGraphT to get the diameter from a graph with 5 million vertices.But it shows that "out of memory java heap space" even I add -Xmx 500000m.How could I ...
ErjiaXiao's user avatar
0 votes
0 answers
78 views

Getting "AWT-EventQueue-0" Exception trying to override toString()

I'm trying to write an algorithm which builds and visualizes a Gomory-Hu-Tree out of a given network, using JGraphT and JGraphX. I read in another post that I had to override the toString() method of ...
Infty's user avatar
  • 13
1 vote
0 answers
172 views

Trying to construct and visualize a Gomory-Hu-Tree using JGraphT and JGraphX

I'm trying to construct and visualize a Gomory-Hu Tree using JGraphT and JGraphX. By reading tutorials or other questions, I've managed to implement a simple weighted graph and a resulting Gomory-Hu ...
Infty's user avatar
  • 13
3 votes
1 answer
283 views

JGraphT: Finding shortest path regardless of Edge Direction

I build the following graph A->B<-C using JGraphT as seen below: DirectedPseudograph<Node, Edge> graph = new DirectedPseudograph<>(Edge.class); DijkstraShortestPath<Node, ...
p192's user avatar
  • 528
1 vote
0 answers
1k views

Styling JgraphT graph visualized in JGraphX

I am trying to set cell style for a graph created with JgraphT and displayed using JGraphX. I was able to successfully set cell style for a graph created directly in JGraphX. Here is the code: ...
Anonimista's user avatar
0 votes
0 answers
476 views

Custom edges supplier error: How to write a generic method?

Trying to make my project independant of Edge and Nodetype I am using as much generics as possible, however when instantiating a new Graph in order to provide an edgetype I followed this: How to get a ...
Sven Heinz's user avatar
1 vote
0 answers
86 views

Need:Search of atomic cycles up to size n

Is there a better way to get all atomic cycles of size up to n then to get all simple cycles and test them? Atomic cycles -> https://en.m.wikipedia.org/wiki/Induced_path EDIT: Is this the same as ...
Sven Heinz's user avatar
0 votes
0 answers
64 views

What's the relation between jgrapht-jdk1.5 and jgrapht-core

I have written a project depended on jgrapht-jdk1.5, but when compile it raise the error "Found duplicate classes/resources in runtime classpath" Detail log: 16:13:27 [WARNING] Found duplicate and ...
Devin Wu's user avatar
  • 121
0 votes
2 answers
889 views

Adding Two Edges - JGraphT

I'm using the SimpleDirectedWeightedGraph from the JGrapghT 1.2.0 library. My aim is to create two edges between the vertices A and B such that A <-80-> B. If I do: graph.addEdge("A", "B", 80); ...
Sahil Pattni's user avatar
0 votes
1 answer
267 views

Inserting a vertex in a GraphPath in Jgrapht

How can I create a new path by expanding an existing one in a graph with JgraphT e.g. after I get the shortest path between two vertices, how can I expand it by inserting an adjacent node in between ...
Nobi's user avatar
  • 1,113
1 vote
1 answer
281 views

JGraphT SimpleGraph and UndirectedGraph

I want make Graph using JGraphT Library. My code is below: private UndirectedGraph<State, DefaultEdge> graph; private HashMap<String, State> vertixList; public MapGraph(HashMap<...
zer0byte's user avatar

1
2
3 4 5
7