Last change
on this file since 9 was
9,
checked in by gnappo, 14 years ago
|
Migrato il resto del codice verso Jung.
|
File size:
937 bytes
|
Line | |
---|
1 | package weka.clusterers.forMetisMQI; |
---|
2 | |
---|
3 | import java.util.Stack; |
---|
4 | |
---|
5 | public class GraphAlgorithms { |
---|
6 | |
---|
7 | public KLPartition KL(UndirectedGraph g) { |
---|
8 | KLPartition partition = new KLPartition(g); |
---|
9 | KLPartition result = partition; |
---|
10 | int bestEdgeCut = Integer.MAX_VALUE; |
---|
11 | Node u = partition.getCandidate(); |
---|
12 | while(u != null) { |
---|
13 | partition.swap(u); |
---|
14 | if(partition.edgeCut() <= bestEdgeCut) { |
---|
15 | bestEdgeCut = partition.edgeCut(); |
---|
16 | result = partition.copy(); |
---|
17 | } |
---|
18 | u = partition.getCandidate(); |
---|
19 | } |
---|
20 | return result; |
---|
21 | } |
---|
22 | |
---|
23 | public void METIS(UndirectedGraph g) { |
---|
24 | KLPartition partition = null; |
---|
25 | Coarse.setFinerSize(10); |
---|
26 | Stack<CoarserGraphElement> stack = Coarse.coarse(g); |
---|
27 | |
---|
28 | if(stack.size() > 0) { |
---|
29 | partition = KL(stack.peek().getContracted()); |
---|
30 | System.out.println(partition.toString()); |
---|
31 | partition = new Uncoarse().uncoarse(stack, partition); |
---|
32 | System.out.println(partition.toString()); |
---|
33 | } |
---|
34 | |
---|
35 | MQI.start(partition); |
---|
36 | |
---|
37 | } |
---|
38 | |
---|
39 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.