1

I'm currently working on a software allowing the creation of gamebooks, and I'm trying to add a graph view. I create a graph where the vertices are the paragraphs and the edges the links between them.

The gamebook I created has over 100 paragraphs, and all of them are extremely interwoven. First I tried to use JGraphX, but the result was a mush after application of the layout. Since help and examples for JGraphX are sparse I couldn't solve it, so I tried my luck with JGraph 5.13, because it had facade (couldn't find the JGraphX equivalent).

My problem is that the facade works pretty well for the first 87 edges I add to it. When I add just one more, I get this exception :

Exception in thread "main" java.lang.IllegalArgumentException: Comparison method violates its general contract!

at java.util.ComparableTimSort.mergeHi(Unknown Source)
at java.util.ComparableTimSort.mergeAt(Unknown Source)
at java.util.ComparableTimSort.mergeForceCollapse(Unknown Source)
at java.util.ComparableTimSort.sort(Unknown Source)
at java.util.ComparableTimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at com.jgraph.layout.hierarchical.JGraphMedianHybridCrossingReduction.medianRank(Unknown Source)
at com.jgraph.layout.hierarchical.JGraphMedianHybridCrossingReduction.weightedMedian(Unknown Source)
at com.jgraph.layout.hierarchical.JGraphMedianHybridCrossingReduction.run(Unknown Source)
at com.jgraph.layout.hierarchical.JGraphHierarchicalLayout.run(Unknown Source)

I'm not sure what to do next. Is JGraph 5.13 not made for making such a chaotic graph? Is there some JGraphX facade equivalent I could use? Am I missing something?

Barranka
  • 20,547
  • 13
  • 65
  • 83
  • can you paste the code where you are doing a comparison – Crickcoder Aug 29 '13 at 20:54
  • This error indicates an incorrect `Comparator` implementation, did you write one? If yes, then please show that as well. – Katona Aug 29 '13 at 22:36
  • I wasn't doing a comparison myself, the exception happens when I do this code (and had 88 or more edges in the graph) : `hir.run(graphFacade); Map nested = graphFacade.createNestedMap(true, true); graph.getGraphLayoutCache().edit(nested);` – GargaLeNoir Aug 30 '13 at 17:34

1 Answers1

3

There is a comparator in 1 or 2 stages of the hierarchical layout that worked with Java 6, but Java 7 started enforcing that they must be must be transitive. We'll look into getting it fixed.

Community
  • 1
  • 1
Frodo Baggins
  • 8,290
  • 6
  • 45
  • 55