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;
}
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);
// }
}
Aggregations