|
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:
1.2 KB
|
| Line | |
|---|
| 1 | package weka.clusterers.forMetisMQI; |
|---|
| 2 | |
|---|
| 3 | import java.util.Iterator; |
|---|
| 4 | import java.util.Stack; |
|---|
| 5 | |
|---|
| 6 | public class Uncoarse { |
|---|
| 7 | |
|---|
| 8 | private boolean projectedBelongs(int u, KLPartition partition, CoarserGraphElement cge) { |
|---|
| 9 | Subgraph s = partition.getSubgraph(); |
|---|
| 10 | int index = cge.getProjected().getIndex(u); |
|---|
| 11 | int mappedNode = cge.getMap().get(index); |
|---|
| 12 | return s.contains(mappedNode); |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | /** |
|---|
| 16 | * Given the projected graph and the partition of the coarser graph, it builds |
|---|
| 17 | * the projected partition. |
|---|
| 18 | * @param partition |
|---|
| 19 | * @param cge |
|---|
| 20 | */ |
|---|
| 21 | public KLPartition uncoarseOneStep(KLPartition partition, CoarserGraphElement cge) { |
|---|
| 22 | Graph projected = cge.getProjected(); |
|---|
| 23 | Subgraph part = new Subgraph(projected); |
|---|
| 24 | Iterator<Integer> projectedIterator = projected.iterator(); |
|---|
| 25 | while(projectedIterator.hasNext()) { |
|---|
| 26 | int u = projectedIterator.next(); |
|---|
| 27 | if(projectedBelongs(u,partition,cge)) |
|---|
| 28 | part.addNode(u); |
|---|
| 29 | } |
|---|
| 30 | return new KLPartition(part); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | public KLPartition uncoarse(Stack<CoarserGraphElement> stack, KLPartition partition) { |
|---|
| 34 | while(stack.size() > 0) { |
|---|
| 35 | CoarserGraphElement element = stack.pop(); |
|---|
| 36 | partition = uncoarseOneStep(partition,element); |
|---|
| 37 | } |
|---|
| 38 | return partition; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | public Uncoarse() { |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.