Questions tagged [jgrapht]
JGraphT is a free Java graph library that provides mathematical graph-theory objects and algorithms.
299
questions
0
votes
0
answers
20
views
Infinite Loop in Blossom/KolmogorovWeightedPerfectMatching algorithm
I'm trying to use the Blossom algorithm in JGraphT to create a pairing between a set of teams using costs based on whether they have already played each other and what their relative point difference ...
0
votes
2
answers
56
views
Jgrapht: how to convert a directed cyclic graph into a DAG?
One thought is run a spanning tree algorithm (e.g., Kruskal) to get the spanning tree, and then construct a new graph from the spanning tree, which is quite messy in terms of code. Looks like there is ...
0
votes
1
answer
45
views
Multiple weights per Edge in a JGraphT DAG
Is there a way in JGraphT that I can assign multiple weights to a single edge? For example, suppose I have a graph representing travel-time between cities. I want to assign edge-weights for "time ...
0
votes
2
answers
45
views
Partition graph into groups of neighbours having the same class
Using JGraphT, I would like partition a graph into groups where each group consists of a connected sub-graph of vertices that have the same "class" (denoted using colors below).
Example -- ...
0
votes
0
answers
77
views
How to set up JGraphT in VSCode?
Can JGraphT also be used in VScode? If so how do I set it up?
I tried looking through JGraphT's documentation, but there were only setup instructions for other IDE's. I also tried downloading the ...
0
votes
0
answers
24
views
Is there any method to save the ContractionHierarchy in files using jgrapht
I have used jgrapht to analyse some graph problems. Now I am working with big graph (with more than ten millions nodes ) and use CH algorithm.
What troubles me is the precomputation of CH is so long, ...
0
votes
1
answer
183
views
Transform jgrapht graph into a Tree
I would like to know if JGraphT has any built-in feature that allows one to export a generated graph into an infinite Tree (parent node/parent children) format.
Tree class
public class Tree<T> {
...
0
votes
0
answers
32
views
how can I use JGrapgT with osmfile
I am new to JGraphT. I have already run ShortestPathDemo, but I want to use it with osmfile.
I have tried importers in org.jgrapht.nio, but I failed.
1
vote
2
answers
56
views
Calculate the subtree formed from a group of nodes to the root node
I have a directed acyclic graph, and I expect to pass in a set of nodes to get a subtree from the root node to them.
For example, in the following figure, if D and E are passed in, a subtree (graph) ...
0
votes
0
answers
88
views
How to nest/group graphs using graphml?
I'm working with Yed and JGraphT to visualize data flow between modules in graphml and I didn't find out how to nest or group graphs. In Yed, there's an option 'group' for nodes so you can unclasp and ...
0
votes
0
answers
34
views
how do I get the closest specific edge to a node with JGraphT
I have a Graph with nodes which are all the same type and edges with different types. Now i want to share the data of every edge of the nodes with the type x to all other edges with different types, ...
0
votes
1
answer
52
views
Personalize PageRank initial scores in jGraphT
I have a question regarding the implementation of PageRank in Java using the jGraphT library.
I need to personalize the initial scores that PageRank gives to nodes. Instead of the usual 1/n, I need to ...
0
votes
0
answers
45
views
JGraphT - Is it possible to export List properties of Vertices & Edges as JSON
I am using JGraphT to create a graph with custom vertices and edge classes. One of the property of the vertex and edge class is a List of String. Everything works fine till I try to export the graph ...
0
votes
0
answers
78
views
Trying to draw a graph but getting Null on weigths
I'm trying to create an image file of a graph with vertices,edges and weigths with JgraphX and mxGraph.
I'm new to this thing of JGraph and stuff and found a tutorial to do this.
But I can't ...
1
vote
1
answer
205
views
How to turn off the edge labels in JGraphX?
I am trying to create a JGraphXAdapter which receives a directed graph as a constructor argument and applied a mxHierarchicalLayout to it. Then, I use mxCellRenderer to create a BufferedImage and ...
1
vote
1
answer
156
views
Algorithm to compress my Graph (JGraphT) by delete certain edges and vertexes
I have a graph that i want to compress by creating a new graph. So the vertexes are "Topological Nodes" and the edges are different objects but they have the same parent class. Now in the ...
1
vote
1
answer
139
views
Identifying disjoined graphs in JgraphT
I have a use case as below. I need to construct a graph from a set of input as below -
SimpleDirectedGraph<String, DefaultEdge> g = new SimpleDirectedGraph<>(DefaultEdge.class);
g....
0
votes
0
answers
79
views
Invalid handle exception in call to AStarShortestPath.getPath
In the execution of the getPath method of AStarShortestPath I am getting exceptions
new IllegalArgumentException("Invalid handle!");
In the graph that is originally created, I added some ...
1
vote
0
answers
31
views
How to draw a undirected weighted graph on a Swing component? [duplicate]
I have this STP file that contains the undirected weighted graph information, this is a sample.
33D32945 STP File, STP Format Version 1.0
SECTION Comment
Name "lin01"
Creator "C. ...
1
vote
1
answer
385
views
Create a JSON object from JgraphT
I have a graph created using JgraphT where I have some data associated with every Node. I need to create a JSON representation of this graph.
For instance I have 3 vertexes : A->B and A->C where ...
1
vote
1
answer
306
views
Calculate longest path for undirected graph where vertices can be visited several times but edges ONLY ONCE
I have an undirected graph and want to calculate the longest possible path between two vertices, where every edge can be visited ONLY ONCE but every vertex can be visited several times.
All the ...
2
votes
1
answer
205
views
Topological sort with detecting vertices that have equal priorities with JGraphT
I introduced JGraphT library to my project and I'm constructing a directed graph of some resources to create with their dependencies. I'm going to use topological sort to determine an order of ...
0
votes
1
answer
129
views
How do I import UnionFind<T> to IntelliJ? (Java)
I want to import this UnionFind- class to my IntelliJ project. But I get a Maven error I do not understand. When I try and type import org.jgrapht.alg.util.UnionFind<T>; in the beginning of my ...
0
votes
0
answers
69
views
Randomly select vertices to be beacons
In our programming assignment, we are tasked with shortest path routing with randomized beacons. Given a graph with n vertices and p beacons that are to be randomly chosen from the vertex set, we are ...
1
vote
1
answer
162
views
How to define cut set with Edmonds Karp Impl?
I'm using JGraphT, and I'm using EdmondsKarpMFImpl.
The question is: How to define the whole set of edges what is 'participate' in min-cut.
I tried to use the getCutEdges method, but it only returns ...
0
votes
1
answer
142
views
How to use custom edge implementation with EdmondsKarp max flow algorithm
I'm trying to implement and simulate a network where I can try some routing methods.
My problem is that one of my routing methods is require me to calculate MaxFlow/MinCut.
I have a custom ...
1
vote
1
answer
94
views
A very large undirected graph computes the shortest path of all vertices. How to improve efficiency? Can it be split and combined?
Now there is a very large undirected graph network, I want to calculate the shortest path between all the vertices of the undirected graph, but the efficiency is very low, can I split and merge the ...
0
votes
1
answer
50
views
Traversal of EdgeReversedGraph
I created a SimpleDirectedGraph and traversed it using a BreadthFirstIterator. Then I created an EdgeReversedGraph of the first graph and traversed that. I was expected the output to be inverted but ...
-1
votes
1
answer
248
views
ConcurrentModificationException using Collectors.toSet()
I have a Set<Objects> that I want to filter by class to obtain a Set<Foo> (i.e., the subset of Objects that are instanceof Foo). To do this with Java-8 I wrote
Set<Foo> filtered = ...
1
vote
1
answer
118
views
How to prune a graph given distance K from a node with jgrapht?
I built a graph using jgrapht API. I have a directed graph. Given a node N, I have to create a subgraph with all connected neighbours with distance K.
So basically given a node, and distance K, I have ...
1
vote
1
answer
135
views
Can vertexes and edges in jGraphT be added parallely
I'm creating a graph in java using jGraphT and adding vertexes and edges from a list using a stream.
My question is:
Can I use stream().parallel() to add them faster?
1
vote
1
answer
51
views
How to create a SimpleWeightedGraph<Node, DefaultEdge> from SpanningTree<DefaultEdge>
I used KruskalMinimumSpanningTree so I can use the getSpanningTree() method.
The method returns a SpanningTree only containing edges (no more nodes). For my export Function I need a graph though...
Is ...
1
vote
2
answers
231
views
Using JGrapht's BreadthFirstIterator, by choosing one particular edge type
I am using JGrapht for an in-memory representation of the employee hierarchy of an organization (SimpleDirectedGraph).
var org = new SimpleDirectedGraph<Employee, EmployeeRelationship>(...
2
votes
0
answers
577
views
Get all Paths between 2 Nodes in a simple graph using JGraphT
I' m currently studying the JGraphT libraries to manipulate Graphs in Java, in particular I'm trying to identify the longest path between 2 nodes in a simple graph and I know that I can get there by ...
1
vote
1
answer
646
views
Group tasks for concurrent processing in directed acyclic dependency graph using topological sorting
I have Task class that has a dependency on other tasks before execution. I want to group tasks that can be parallelized and order them. I decide that it can be represented as DAG first and trying to ...
2
votes
1
answer
350
views
Does this look like an efficient way to find vertices which have no outgoing edges in a graph (JGrapthT)?
I am using JGraphT for holding about 150,000 (or thereabouts) vertices in an in-memory graph. This a directed graph and each vertex is going to have { 0 | 1 } outgoing edges.
I want to find retrieve ...
0
votes
1
answer
375
views
Error when computing DijkstraShortestPath in JGrapht
I am writing a Google Cloud Function to return a distance frontier in a Polygon from a given source Vertex within the polygon. I am getting an error message saying:
java.lang.IllegalArgumentException: ...
1
vote
1
answer
377
views
JGraphT exporting a weighted graph And importing it
I'm looking for a method to export my graph with the weighted edges.
I have a simple directed graph with weighted edges.
SimpleDirectedWeightedGraph<Integer, DefaultWeightedEdge> exGraph =
...
1
vote
1
answer
447
views
How to find all paths in a graph that start with some initial partial path?
There is the following part of the code:
SimpleDirectedGraph<String, DefaultEdge> multigraph = new SimpleDirectedGraph<>(DefaultEdge.class);
multigraph.addVertex("a");
multigraph....
-1
votes
1
answer
109
views
Build GraphPath from list of vertices
Is there a way in which I can build a GraphPath of one graph using just its list of vertices to create a path from another graph in SimpleDirectedWeightedGraph?
For example, lets say i do a ....
0
votes
0
answers
96
views
Is there a function in JGraphT like k_edge_components() in networkx
A k-edge-connected component is a set of nodes which remain connected even after removing any k edges.
Is there a function can do this in JGraphT? If not, is there a java graph lib having this ...
14
votes
1
answer
2k
views
Finding all the paths between two vertices with weight limit in a directed graph
I'm trying to find all the paths between two vertices that have weight less than N in a directed weighted graph that may have loops but not self-loops. So far, I could do it only by using ...
0
votes
1
answer
353
views
Is there a DAG with weighted edges?
I'd like to create a DAG in order to use the TopologicalOrderIterator and would like to save some weights on the edges. However, a DAG does not allow weighted edges and the TopologicalOrderIterator is ...
1
vote
1
answer
609
views
How to use CSVImporter and create vertex supplier
I can't find any documentation on how to use the CSVImporter (1.5.0). I have a very simple csv file with integers that I'm trying to import using the following code:
Graph<String, DefaultEdge> ...
0
votes
1
answer
465
views
Get all subgraphs in JGraphT
How can I get all possible subgraphs of a graph in JGraphT in a List<MyGraph> or Set<MyGraph> collection?
I've read the documentation of JGraphT, but I couldn't find anything to help me ...
2
votes
1
answer
211
views
How to map jgrapht Graph<Foo,E> to another Graph<Bar,E>?
I have the following graph:
private final Graph<Foo, DefaultWeightedEdge> graph = buildGraph();
@Override
public Graph<Foo, DefaultWeightedEdge> buildGraph() {
return ...
0
votes
1
answer
582
views
jGraphT - Remove a vertex and reconnect all vertices which were connected to the removed one
I`m new to graphs and fiddling around with JGraphT at the moment. I have a simple graph where I want to remove a certain vertex. Removing is no problem at all but I need to reconnect all the vertices ...
0
votes
1
answer
570
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 ...
0
votes
1
answer
354
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 ...
0
votes
1
answer
297
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 ...