Commit a07ee7a0 by Guilhelm Savin

### Fix WelshPowell algorithm

parent 46be959f
 ... ... @@ -31,12 +31,10 @@ */ package org.graphstream.algorithm.coloring; import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; import java.util.PriorityQueue; import java.util.LinkedList; import org.graphstream.algorithm.Algorithm; import org.graphstream.algorithm.util.FibonacciHeap; import org.graphstream.graph.Graph; import org.graphstream.graph.Node; ... ... @@ -76,72 +74,44 @@ import org.graphstream.graph.Node; *

* After computation (using {@link #compute()}, the algorithm result for the * computation, the chromatic number, is accessible with the * {@link #getChromaticNumber()} method. Colors (of "Integer" type) are stored in the graph as attributes (one for each node). * By default the attribute name is "WelshPowell.color", but you can optional choose the * attribute name. * {@link #getChromaticNumber()} method. Colors (of "Integer" type) are stored * in the graph as attributes (one for each node). By default the attribute name * is "WelshPowell.color", but you can optional choose the attribute name. *

* * * *

Example

* import java.io.IOException; * import java.io.StringReader; *

Example

* The chromatic number of this graph is : 3
* Node D : color 0
...  ...  @@ -156,33 +126,33 @@ import org.graphstream.graph.Node;
*

Extra Feature

* *

* Consider you what to display the result of they coloring algorithm on a displayed graph, * then adding the following code to the previous example may help you: * Consider you what to display the result of they coloring algorithm on a * displayed graph, then adding the following code to the previous example may * help you: *

* *
* Color[] cols = new Color[wp.getChromaticNumber()];
* for(int i=0;i< wp.getChromaticNumber();i++){
* 	cols[i]=Color.getHSBColor((float) (Math.random()), 0.8f, 0.9f);
* for (int i = 0; i < wp.getChromaticNumber(); i++) {
* 	cols[i] = Color.getHSBColor((float) (Math.random()), 0.8f, 0.9f);
* }
* for(Node n : graph){
* 	int col = (int) n.getNumber("color");
* for (Node n : graph) {
* 	int col = (int) n.getNumber("color");
* 	n.addAttribute("ui.style", "fill-color:rgba(" + cols[col].getRed() + ","
* 			+ cols[col].getGreen() + "," + cols[col].getBlue() + ",200);");
* }
*
* graph.display();
*