Search in sources :

Example 1 with Vertex

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;
}
Also used : Vertex(model.graph.ContractedGraph.Vertex)

Example 2 with Vertex

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);
}
Also used : Vertex(model.graph.ContractedGraph.Vertex)

Example 3 with Vertex

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);
    }
}
Also used : Vertex(model.graph.ContractedGraph.Vertex) UndirectedEdge(org._3pq.jgrapht.edge.UndirectedEdge)

Example 4 with Vertex

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);
}
Also used : Vertex(model.graph.ContractedGraph.Vertex) HashSet(java.util.HashSet)

Example 5 with Vertex

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 = "";
    }
}
Also used : Vertex(model.graph.ContractedGraph.Vertex) UndirectedEdge(org._3pq.jgrapht.edge.UndirectedEdge)

Aggregations

Vertex (model.graph.ContractedGraph.Vertex)5 UndirectedEdge (org._3pq.jgrapht.edge.UndirectedEdge)2 HashSet (java.util.HashSet)1