Search in sources :

Example 1 with DefaultHyperEdge

use of fr.lirmm.graphik.util.graph.DefaultHyperEdge in project graal by graphik-team.

the class BCCScheduler method constructHyperGraph.

/**
 * The HyperGraph of variables of h. There is an hyper edge between a set of
 * variables if they appear in a same atom.
 *
 * @param h
 * @return the HyperGraph of variables of h.
 */
protected static HyperGraph constructHyperGraph(InMemoryAtomSet h, int nbVariables, Term[] inverseMap, Map<Term, Integer> map, Iterable<Term> ans) {
    HyperGraph graph = new DefaultHyperGraph(nbVariables + 1);
    CloseableIteratorWithoutException<Atom> it = h.iterator();
    while (it.hasNext()) {
        Atom a = it.next();
        DefaultHyperEdge edge = new DefaultHyperEdge();
        int arity = 0;
        for (Variable t : a.getVariables()) {
            ++arity;
            edge.addVertice(map.get(t));
        }
        if (arity >= 2) {
            graph.add(edge);
        }
    }
    return graph;
}
Also used : Variable(fr.lirmm.graphik.graal.api.core.Variable) DefaultHyperGraph(fr.lirmm.graphik.util.graph.DefaultHyperGraph) DefaultHyperEdge(fr.lirmm.graphik.util.graph.DefaultHyperEdge) DefaultHyperGraph(fr.lirmm.graphik.util.graph.DefaultHyperGraph) HyperGraph(fr.lirmm.graphik.util.graph.HyperGraph) Atom(fr.lirmm.graphik.graal.api.core.Atom)

Aggregations

Atom (fr.lirmm.graphik.graal.api.core.Atom)1 Variable (fr.lirmm.graphik.graal.api.core.Variable)1 DefaultHyperEdge (fr.lirmm.graphik.util.graph.DefaultHyperEdge)1 DefaultHyperGraph (fr.lirmm.graphik.util.graph.DefaultHyperGraph)1 HyperGraph (fr.lirmm.graphik.util.graph.HyperGraph)1