From: Nick E. <nic...@gm...> - 2012-12-05 11:44:52
|
Dear all, I have just started using JGraphT and have got it to produce a graph from my data. I can get the edgeSet().size() and vertexSet().size fine, but if I try to calculate the Chromatic number I get 1 no matter what the number of edges and vertices! The code I am using is bellow: (where create.getCluster(x) returns a graph generated from some data). UndirectedGraph<StringCount, DefaultEdge> graph = create.getCluster(x); int colour=ChromaticNumber.findGreedyChromaticNumber(graph); System.out.println("Cluster with "+graph.edgeSet().size()+" edges and "+graph.vertexSet().size()+" verticies "+" colours:"+colour); which gives the output bellow: Cluster with 8 edges and 5 vertices colours:1 Cluster with 47 edges and 14 vertices colours:1 Cluster with 4 edges and 4 vertices colours:1 Cluster with 478 edges and 90 vertices colours:1 Cluster with 34 edges and 14 vertices colours:1 Cluster with 13 edges and 24 vertices colours:1 It seems a bit unusual that .findGreedyChromaticNumber always returns 1! My Vertex class is a Pair of a String and an int which delegates the hashCode() and equals() methods to the string it contains. Any help would be appreciated! Thanks Nick England |