Search in sources :

Example 1 with DefaultHyperGraph

use of fr.lirmm.graphik.util.graph.DefaultHyperGraph 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)

Example 2 with DefaultHyperGraph

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

the class BiconnectedComponentsForHyperGraph method main.

public static void main(String[] args) {
    DefaultHyperGraph g = new DefaultHyperGraph(20);
    g.addEdge(1, 2, 3);
    g.addEdge(3, 4);
    g.addEdge(14, 10);
    g.addEdge(10, 12, 13);
    g.addEdge(10, 7, 11);
    g.addEdge(7, 11);
    g.addEdge(5, 6, 7, 8);
    g.addEdge(7, 8, 9);
    g.addEdge(8, 19, 20);
    g.addEdge(9, 18);
    g.addEdge(9, 15);
    g.addEdge(15, 16, 17);
// List<Set<Integer>> components =
// BiconnectedComponentsForHyperGraph.execute(g);
// for (Set<Integer> c : components) {
// System.out.println(c);
// }
}
Also used : DefaultHyperGraph(fr.lirmm.graphik.util.graph.DefaultHyperGraph)

Aggregations

DefaultHyperGraph (fr.lirmm.graphik.util.graph.DefaultHyperGraph)2 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 HyperGraph (fr.lirmm.graphik.util.graph.HyperGraph)1