|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.graphstream.algorithm.AbstractSpanningTree
org.graphstream.algorithm.Kruskal
public class Kruskal
Compute a spanning tree using the Kruskal algorithm.
Kruskal's algorithm is a greedy algorithm which allows to find a minimal spanning tree in a weighted connected graph. More informations on Wikipedia.
import org.graphstream.graph.Graph;
import org.graphstream.graph.implementations.DefaultGraph;
import org.graphstream.algorithm.Kruskal;
import org.graphstream.algorithm.generator.DorogovtsevMendesGenerator;
public class KruskalTest {
public static void main(String .. args) {
DorogovtsevMendesGenerator gen = new DorogovtsevMendesGenerator();
Graph graph = new DefaultGraph("Kruskal Test");
String css = "edge .notintree {size:1px;fill-color:gray;} " +
"edge .intree {size:3px;fill-color:black;}";
graph.addAttribute("ui.stylesheet", css);
graph.display();
gen.addEdgeAttribute("weight");
gen.setEdgeAttributesRange(1, 100);
gen.addSink(graph);
gen.begin();
for (int i = 0; i < 100 && gen.nextEvents(); i++)
;
gen.end();
Kruskal kruskal = new Kruskal("ui.class", "intree", "notintree");
kruskal.init(g);
kruskal.compute();
}
}
AbstractSpanningTree| Constructor Summary | |
|---|---|
Kruskal()
Create a new Kruskal's algorithm. |
|
Kruskal(String flagAttribute,
Object flagOn,
Object flagOff)
Create a new Kruskal's algorithm. |
|
Kruskal(String weightAttribute,
String flagAttribute)
Create a new Kruskal's algorithm. |
|
Kruskal(String weightAttribute,
String flagAttribute,
Object flagOn,
Object flagOff)
Create a new Kruskal's algorithm. |
|
| Method Summary | |
|---|---|
String |
getWeightAttribute()
Get key attribute used to compare edges. |
void |
setWeightAttribute(String newWeightAttribute)
Set the weight attribute. |
| Methods inherited from class org.graphstream.algorithm.AbstractSpanningTree |
|---|
compute, getFlagAttribute, getFlagOff, getFlagOn, init, setFlagAttribute, setFlagOff, setFlagOn |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Kruskal()
public Kruskal(String weightAttribute,
String flagAttribute)
weightAttribute - attribute used to compare edgesflagAttribute - attribute used to set if an edge is in the spanning tree
public Kruskal(String flagAttribute,
Object flagOn,
Object flagOff)
flagAttribute - attribute used to set if an edge is in the spanning treeflagOn - value of the flagAttribute if edge is in the spanning
treeflagOff - value of the flagAttribute if edge is not in the
spanning tree
public Kruskal(String weightAttribute,
String flagAttribute,
Object flagOn,
Object flagOff)
weightAttribute - attribute used to compare edgesflagAttribute - attribute used to set if an edge is in the spanning treeflagOn - value of the flagAttribute if edge is in the spanning
treeflagOff - value of the flagAttribute if edge is not in the
spanning tree| Method Detail |
|---|
public String getWeightAttribute()
public void setWeightAttribute(String newWeightAttribute)
newWeightAttribute - new attribute used
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||