Last change
on this file since 10 was
9,
checked in by gnappo, 14 years ago
|
Migrato il resto del codice verso Jung.
|
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(Node u, KLPartition partition, CoarserGraphElement cge) { |
---|
9 | Subgraph s = partition.getSubgraph(); |
---|
10 | Node mappedNode = cge.getMap().get(u); |
---|
11 | return s.contains(mappedNode); |
---|
12 | } |
---|
13 | |
---|
14 | /** |
---|
15 | * Given the projected graph and the partition of the coarser graph, it builds |
---|
16 | * the projected partition. |
---|
17 | * @param partition |
---|
18 | * @param cge |
---|
19 | */ |
---|
20 | public KLPartition uncoarseOneStep(KLPartition partition, CoarserGraphElement cge) { |
---|
21 | UndirectedGraph projected = cge.getProjected(); |
---|
22 | Subgraph part = new Subgraph(projected); |
---|
23 | Iterator<Node> projectedIterator = projected.getVertices().iterator(); |
---|
24 | while(projectedIterator.hasNext()) { |
---|
25 | Node u = projectedIterator.next(); |
---|
26 | if(projectedBelongs(u,partition,cge)) |
---|
27 | part.addVertex(u); |
---|
28 | } |
---|
29 | return new KLPartition(part); |
---|
30 | } |
---|
31 | |
---|
32 | public KLPartition uncoarse(Stack<CoarserGraphElement> stack, KLPartition partition) { |
---|
33 | while(stack.size() > 0) { |
---|
34 | CoarserGraphElement element = stack.pop(); |
---|
35 | partition = uncoarseOneStep(partition,element); |
---|
36 | } |
---|
37 | return partition; |
---|
38 | } |
---|
39 | |
---|
40 | public Uncoarse() { |
---|
41 | } |
---|
42 | |
---|
43 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.