|
Last change
on this file since 7 was
7,
checked in by gnappo, 15 years ago
|
|
Implementazione di Metis: aggiunta fase di uncoarsing e algoritmo di bisezione. Un po' di refactoring.
|
|
File size:
861 bytes
|
| Line | |
|---|
| 1 | package weka.clusterers.forMetisMQI; |
|---|
| 2 | |
|---|
| 3 | import java.util.Stack; |
|---|
| 4 | |
|---|
| 5 | public class GraphAlgorithms { |
|---|
| 6 | |
|---|
| 7 | public KLPartition KL(Graph g) { |
|---|
| 8 | KLPartition partition = new KLPartition(g); |
|---|
| 9 | KLPartition result = partition; |
|---|
| 10 | int bestEdgeCut = Integer.MAX_VALUE; |
|---|
| 11 | int u = partition.getCandidate(); |
|---|
| 12 | while(u != -1) { |
|---|
| 13 | partition.swap(u); |
|---|
| 14 | if(partition.edgeCut() <= bestEdgeCut) { |
|---|
| 15 | bestEdgeCut = partition.edgeCut(); |
|---|
| 16 | result = partition.clone(); |
|---|
| 17 | } |
|---|
| 18 | u = partition.getCandidate(); |
|---|
| 19 | } |
|---|
| 20 | return result; |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | public void METIS(Graph g) { |
|---|
| 24 | KLPartition partition = null; |
|---|
| 25 | Stack<CoarserGraphElement> stack = Coarse.coarse(g); |
|---|
| 26 | |
|---|
| 27 | if(stack.size() > 0) { |
|---|
| 28 | partition = KL(stack.peek().getContracted()); |
|---|
| 29 | System.out.println(partition.toString()); |
|---|
| 30 | partition = new Uncoarse().uncoarse(stack, partition); |
|---|
| 31 | System.out.println(partition.toString()); |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.