jgrapht

Show weights in JgraphT

I have implemented this Graph: ListenableDirectedWeightedGraph g = new ListenableDirectedWeightedGraph( MyWeightedEdge.class); in order to show what the class name says, a simple listenable directed weighted graph. I want to change the label of the edges and instead of the format return "(" + source + " : " + target + ")"; I wa...

Java: JGraphT: Iterate through nodes

I'm trying to iterate through all nodes, so I can print them out for graphviz. What is the best way to do that using the JGraphT library? public static void main(String[] args) { UndirectedGraph<String, DefaultEdge> g = new SimpleWeightedGraph<String, DefaultEdge>(DefaultEdge.class); String odp = "ODP"; String cck = "CCK"; String m...

Java: Minimum spanning tree with JGraphT?

I have a problem that can essentially be viewed as a graph. I'm considering using JGraphT to implement it instead of rolling my own. What would be the best way to get a minimum spanning tree out of a graph using JGraphT? ...

Java: Prim's with Fibonacci heap? (JGraphT)

JGraphT has a nice Fibonacci Heap class. How can I use it to implement Prim's minimum spanning tree algorithm? ...

Java: How does my Prim's look?

I am trying to implement Prim's minimum spanning tree algorithm with JGraphT. How does it look? One issue I ran into was JGraphT's handling of everything like it's directed. So sometimes it is necessary to make some awkward calls to reverse g.getEdgeSource(e) and g.getEdgeTarget(e) if they didn't happen to be right. I tried to implemen...

Java Code Review: Generate a subgraph

I'm using JGraphT and I want to generate a subgraph, like this: If there's a graph like {stuff -> a -> b -> stuff}, and you ask for the subgraph in direction of {a -> b}, you'll get {a -> b -> stuff}. (stuff = collection of nodes and edges, -> = an edge, a and b are nodes.) My idea is as follows: if the start is A, and the sink is B, r...

Java: Why does this method have side effects?

I have a method that is producing side effects, even though certain variables are marked final. Why is this? Perhaps I am confused about what final does. @Test public void testSubGraph() { WeightedGraph<String, DefaultWeightedEdge> g = generateSimpleCaseGraph(); Graph<String, DefaultWeightedEdge> sub = ChooseRoot.subgraphInDirection(...

Java: .equals() failing for sets (JGraphT)

I can't figure out what's going wrong here. This test fails: @Test public void testSimpleCase() { assertTrue(JGraphtUtilities.graphEquality(ChooseRootTest.generateSimpleCaseGraph(), ChooseRootTest.generateSimpleCaseGraph())); } public static <V, E> boolean graphEquality(Graph<V, E> g0, Graph<V, E> g1) { boolean result = ...

Graph Theory: Find the Jordan center?

I'm trying to find the set of vertices that minimizes their distance to other vertices on a weighted graph. Based on a cursory wikipedia search, I think that this is called the Jordan Center. What are some good algorithms for finding it? Right now, my plan is to get a list of the weight for each branch emanating from a given vertex. The...

Java: edit and recompile .jar?

I downloaded JGraphT, and I want to make some changes to the core files. I'm using Eclipse. It wants a .jar or .zip to attach source files to the .class file. I have the .java file, but I'm not sure what I should do. Do I edit it, then recompile the jar? ...

JGraph - overriding cell drag

Hi, This is quite a long shot, I know it's a question about a very specific package. I'm trying to stop nodes from dragging into a certain area of the graph. I have written code to detect when the mouse is dragged over a node, however it is a bit of a hack. I am trying to get the node that the mouse is dragging and its XY co-ordinates...

Java library for trees similar to JGraphT for graphs?

I'm a big fan of JGraphT, a Java library for graphs. Could anyone recommend a similar Java library for trees? Preferrably FOSS. What I need is a good API, preferrably typesafe with generics which allows modelling different kinds of trees (with some user data attached to verticies/edges) and run different algorithms and operations on the...

import jgrapht package into my netbeans project

Hi I am not knowing how to use the classes written in netbeans for one of my project . in which folder should i place the jgrapht package . will i have to write the import statement if yes then what do i write ? ...

jgrapht-jdk1.6 "HelloJGraphT.java" compilation problem

Hi, JGraphT package includes some examples to experiment oneself. HelloJGraphT.java is one of them. I can run it, without any error, in Netbeans6.0.1. But, when i use dos command prompt in the following way: javac -cp jgrapht-jdk1.6.jar HelloJGraphT.java it compiles. But, if i run it using: java HelloJGraphT it gives the fol...