use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.
the class AutomaticCluster method moveNode.
/**
* Moves v from its original cluster to the one indexed by 'to'. It is much
* faster than calculating the whole matrix again.
*
* @param v
* The node to be moved
* @param to
* The index of the cluster
*/
private void moveNode(final NodeDescriptor v, final int to) {
final int from = mapClusterIndex.get(v);
if (from == to) {
return;
}
if (size.get(to) == 0) {
clusternum++;
}
if (size.get(from) == 1) {
clusternum--;
}
for (final EdgeDescriptor e : moduleGraph.getInEdges(v)) {
final NodeDescriptor u = moduleGraph.getSource(e);
final int indexu = mapClusterIndex.get(u);
changeCell(from, indexu, -1);
changeCell(to, indexu, 1);
}
for (final EdgeDescriptor e : moduleGraph.getOutEdges(v)) {
final NodeDescriptor w = moduleGraph.getDest(e);
final int indexw = mapClusterIndex.get(w);
changeCell(indexw, from, -1);
changeCell(indexw, to, 1);
}
changeSize(from, -1);
changeSize(to, 1);
mapClusterIndex.put(v, to);
}
use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.
the class FullModuleNameCluster method createGraph.
@Override
public void createGraph() {
mapNameNode = new HashMap<String, ClusterNode>();
clusterGraph = new DirectedSparseGraph<NodeDescriptor, EdgeDescriptor>();
stack = new LinkedList<String>();
ClusterNode root = new ClusterNode(ALL, mapNameCluster.get(ALL));
clusterGraph.addVertex(root);
mapNameNode.put(ALL, root);
traverseListOfNames();
}
use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.
the class ModuleNameCluster method fillClusters.
/**
* Fill the clusters with the nodes.
*/
private void fillClusters() {
for (final NodeDescriptor v : moduleGraph.getVertices()) {
final String name = v.getDisplayName();
int length = 0;
String match = null;
for (final String word : knownNames) {
if (word.length() > length && name.startsWith(word)) {
match = word;
length = word.length();
}
}
if (match == null) {
final Set<NodeDescriptor> cluster = mapNameCluster.get(ALL);
cluster.add(v);
v.setCluster(cluster);
} else {
final Set<NodeDescriptor> cluster = mapNameCluster.get(match);
cluster.add(v);
v.setCluster(cluster);
}
}
for (final String word : knownNames) {
final Set<NodeDescriptor> cluster = mapNameCluster.get(word);
if (!cluster.isEmpty()) {
clusters.add(cluster);
}
}
}
use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.
the class PathCluster method addMissing.
/**
* Adds the missing modules to a separate cluster.
*/
protected void addMissing() {
final Set<NodeDescriptor> missing = new HashSet<NodeDescriptor>();
for (final NodeDescriptor v : moduleGraph.getVertices()) {
if (v.getCluster() == null) {
missing.add(v);
v.setCluster(missing);
}
}
if (!missing.isEmpty()) {
clusters.add(missing);
mapNameCluster.put("missing", missing);
}
}
use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.
the class PathCluster method init.
/**
* Initializes the algorithm.
*/
protected void init() {
for (final NodeDescriptor v : moduleGraph.getVertices()) {
v.setCluster(null);
mapNameNode.put(v.getName(), v);
}
}
Aggregations