关键价值关系的最小组合

时间:2013-11-22 17:17:58

标签: java

我有一个像这样的二维数组

x = new ArrayList<String>();
y = new ArrayList<String>();

[put data in x/y]

// generate field
this.grid = new boolean[x.size()][y.size()];
for (String xId: x) {
    for (String yId: y) {
        this.grid[x.indexOf(xId)][y.indexOf(yId)] = false;
    }
}

// parse to field
for (Map.Entry<String, ArrayList<String>> element : this.relations.entrySet()) {
    int xId = x.indexOf(element.getKey());
    for (String selector: element.getValue()) {
        int yId = y.indexOf(selector);
        this.grid[xId][yId] = true;
    }
}

结果

     y1 y2 y3 y4 y5 y6 y7 y8 y9
    ___________________________ 
x1 |  -  -  -  X  -  X  X  -  - 
x2 |  X  -  X  -  -  -  -  X  -
x3 |  X  -  X  -  -  -  -  -  X 
x4 |  -  -  X  -  -  -  -  -  -
x5 |  -  X  -  X  X  X  X  -  -
x6 |  X  -  -  -  -  -  -  -  X
x7 |  -  -  -  X  -  X  X  -  -
x8 |  -  -  X  -  -  -  -  -  -
x9 |  X  X  -  -  X  -  -  -  X

结果基本上给出了这个信息:

x1 => [y4, y6, y7]
x2 => [y1, y3, y8]
x3 => [y1, y3, y9]
x4 => [y3]
...

分别为:

y1 => [x2, x3, x6, x9]
y2 => [x5,x9]
...

所以这个输入:

x1 => [y4, y6, y7]
x2 => [y1, y3, y8]
x3 => [y1, y3, y9]

结果应如下所示:

[x1]     => [y4, y6, y7]
[x2, x3] => [y1, y3]
[x2]     => [y8]
[x3]     => [y9]

我把它称为最小组合..;)

任何想法?想法?提示? ^^

经过一段时间的观察,我认为问题区域被称为“正式概念分析”

0 个答案:

没有答案