|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.wwu.tobikley.acgc.algorithms.CountingAlgorithm edu.wwu.tobikley.acgc.algorithms.NaiveCountingAlgorithm
public class NaiveCountingAlgorithm
Implements a Naive Counting Algorithm as a CountingAlgorithm
.
To determine the exact number of proper q-Colorings the following steps
are performed:
Field Summary | |
---|---|
private int[] |
coloring
The current coloring checked by the algorithm. |
protected HashMap<Vertex,Integer> |
verticeNames
Mapping the graphs vertices to Integer ids. |
private int |
watchedColor
Color previously watched at the watchIndex of
coloring . |
private int |
watchIndex
Specified position in coloring to watch for changes
to report progress. |
Fields inherited from class edu.wwu.tobikley.acgc.algorithms.CountingAlgorithm |
---|
detailedResults, endTime, graphBackup, graphWorkingCopy, numberOfColors, progress, progressText, returnVal, startTime |
Constructor Summary | |
---|---|
NaiveCountingAlgorithm(Graph g,
int numberOfColors)
Creates a new instance of a naive counting algorithm. |
Method Summary | |
---|---|
void |
algorithm()
Iterates through all possible q-Colorings and calls isValid
to determine if it is proper. |
private boolean |
isProperVertexColoring()
Checks if a q-Coloring is proper regarding the graphWorkingCopy . |
private void |
setProgress()
If necessary progress and progressText are updated. |
private void |
setProgressText(String progressText)
|
Methods inherited from class edu.wwu.tobikley.acgc.algorithms.CountingAlgorithm |
---|
call, getDetailedResults, getGraph, getNumberOfColors, getProgress, getProgressText, getRunTime, setNumberOfColors |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int[] coloring
private int watchIndex
coloring
to watch for changes
to report progress. The position is chosen, so that there are least
possible but at last 100 changes in color.
private int watchedColor
watchIndex
of
coloring
.
protected HashMap<Vertex,Integer> verticeNames
Constructor Detail |
---|
public NaiveCountingAlgorithm(Graph g, int numberOfColors)
CountingAlgorithm
and
initializes verticeNames
and the watchIndex
.
g
- The graph to calculate the number of q-Colorings from.numberOfColors
- The number q as the question is: How many q-Colorings are there.Method Detail |
---|
private boolean isProperVertexColoring()
graphWorkingCopy
.
To determine if it is a proper q-Colorings, each edge in the graph is
examined. A coloring is proper if the endnodes of all edges are of
different colors.
true
if coloring
is a proper q-Coloring, and
false
if it is not.public void algorithm()
isValid
to determine if it is proper. Before the coloring is checked,
setProgress
is called, to propagate the progress of the
calculation.
algorithm
in class CountingAlgorithm
private void setProgress()
progress
and progressText
are updated.
The progressText
is set to the text: "Calculation is xx% finished.".
private void setProgressText(String progressText)
progressText
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |