protected void cleanUpEdges(double significanceThreshold, double correlationThreshold) { for (int x = 0; x < graph.getNumberOfInitialNodes(); x++) { for (int y = 0; y < graph.getNumberOfInitialNodes(); y++) { if (graph.getNodeMappedTo(x) == null || graph.getNodeMappedTo(y) == null || (graph.getBinarySignificance(x, y) < significanceThreshold && graph.getBinaryCorrelation(x, y) < correlationThreshold)) { graph.setBinarySignificance(x, y, 0.0); graph.setBinaryCorrelation(x, y, 0.0); } } } }
/* * (non-Javadoc) * * @see * org.processmining.mining.fuzzymining.graph.transform.FuzzyGraphTransformer * #transform(org.processmining.mining.fuzzymining.graph.FuzzyGraph) */ public void transform(MutableFuzzyGraph graph) { this.graph = graph; // clean up edges cleanUpEdges(threshold * 0.1, 1.0); // threshold * 0.3); // determine simplification victims ArrayList<Node> simplificationVictims = new ArrayList<Node>(); Node n; for (int i = 0; i < graph.getNumberOfInitialNodes(); i++) { n = graph.getPrimitiveNode(i); if (n.getSignificance() < threshold) { simplificationVictims.add(n); } } // create clusters int clusterIndex = graph.getNumberOfInitialNodes() + 1; while (simplificationVictims.size() > 0) { ClusterNode cluster = new ClusterNode(graph, clusterIndex); graph.addClusterNode(cluster); clusterIndex++; boolean nodeAdded = true; while (nodeAdded == true) { nodeAdded = false; ArrayList<Node> clustered = new ArrayList<Node>(); for (Node node : simplificationVictims) { if (shouldMergeWith(node, cluster) == true) { cluster.add(node); graph.setNodeAliasMapping(node.getIndex(), cluster); clustered.add(node); nodeAdded = true; } } simplificationVictims.removeAll(clustered); } } // merge clusters mergeAllClusters(); // remove unary clusters for (int i = graph.getClusterNodes().size() - 1; i >= 0; i--) { ClusterNode cluster = graph.getClusterNodes().get(i); if (cluster.getPrimitives().size() == 1) { // unary cluster; remove for (int k = 0; k < graph.getNumberOfInitialNodes(); k++) { Node mapping = graph.getNodeMappedTo(k); if (mapping != null && mapping.equals(cluster)) { graph.setNodeAliasMapping(k, null); } } graph.removeClusterNode(cluster); } } // clean up edges cleanUpEdges(threshold, threshold); }