use of model.graph.ContractedGraph.Vertex in project Smiles2Monomers by yoann-dufresne.
the class Neighborhood method highest.
public Vertex highest() {
Vertex v = null;
int score = 0;
for (Vertex candidate : this.keySet()) if (this.get(candidate) > score) {
v = candidate;
score = this.get(candidate);
}
return v;
}
use of model.graph.ContractedGraph.Vertex in project Smiles2Monomers by yoann-dufresne.
the class RemoveMostNeighboorsMatchs method remove.
@Override
public void remove(Coverage cov, ContractedGraph cg) {
this.neig.calculate(cg);
while (this.neig.size() > 0) {
Vertex v = this.neig.highest();
cov.removeUsedMatch(v.res, v.vertices);
this.adaptGraph(cg, v);
this.neig.calculate(cg);
}
this.cleanGraph(cg);
}
use of model.graph.ContractedGraph.Vertex in project Smiles2Monomers by yoann-dufresne.
the class Neighborhood method calculate.
public void calculate(ContractedGraph cg) {
this.clear();
for (Object o : cg.vertexSet()) {
Vertex v = (Vertex) o;
if (v.id.startsWith("?"))
continue;
int nb = 0;
for (Object o2 : cg.edgesOf(v)) {
UndirectedEdge e = (UndirectedEdge) o2;
Vertex source = (Vertex) e.getSource();
Vertex target = (Vertex) e.getTarget();
if (source.id.startsWith("?") || target.id.startsWith("?"))
nb++;
}
if (nb > 0)
this.put(v, nb);
}
}
use of model.graph.ContractedGraph.Vertex in project Smiles2Monomers by yoann-dufresne.
the class RemoveByDistance method removeRecur.
private void removeRecur(Coverage cov, ContractedGraph cg, int currentDist) {
if (this.distance == currentDist)
return;
Set<Vertex> neighbors = new HashSet<>();
for (Object o : cg.vertexSet()) {
Vertex v = (Vertex) o;
if (v.id.startsWith("?")) {
neighbors.addAll(cg.getNeighbors(v));
}
}
for (Vertex n : neighbors) {
if (n.res == null)
continue;
cov.removeUsedMatch(n.res, n.vertices);
n.res = null;
n.id = "?";
}
this.removeRecur(cov, cg, currentDist + 1);
}
use of model.graph.ContractedGraph.Vertex in project Smiles2Monomers by yoann-dufresne.
the class RemoveMostNeighboorsMatchs method adaptGraph.
private void adaptGraph(ContractedGraph cg, Vertex v) {
for (Object o : cg.edgesOf(v)) {
UndirectedEdge ue = (UndirectedEdge) o;
Vertex source = (Vertex) ue.getSource();
if (source.id.startsWith("?"))
source.id = "";
Vertex target = (Vertex) ue.getTarget();
if (target.id.startsWith("?"))
target.id = "";
}
}
Aggregations