-
Notifications
You must be signed in to change notification settings - Fork 9
Using CHGL in Code
Louis Jenkins edited this page Feb 6, 2019
·
3 revisions
Import CHGL into your project like such...
use CHGL;Instantiating a Hypergraph
const numVertices = 1024;
const numEdges = 2048;
const distribution = new unmanaged Cyclic(startIdx=1);
var graph = new AdjListHyperGraph(numVertices, numEdges, distribution);Instantiating via a PropertyMap
type VertexProperty;
type EdgeProperty;
var pmap = new PropertyMap(VertexProperty, EdgeProperty);
const distribution = new unmanaged Block(...);
forall (x,y) in someData {
pmap.addVertexProperty(x);
pmap.addEdgeProperty(y);
}
var graph = new AdjListHyperGraph(pmap, distribution);Inserting into Hypergraph
// Obtain index from property map (optional)
const vp : VertexProperty;
const ep : EdgeProperty;
const vIdx = pmap.getVertexProperty(vp);
const eIdx = pmap.getEdgeProperty(ep);
// Add edge from vertex to edge
graph.addInclusion(vIdx, eIdx);Iterating Over Hypergraph
// Parallel + Distributed Iteration over vertices
forall v in graph.getVertices() {
// Serial Iteration over edges that v is incident in
for e in graph.incidence(v) {
// Print degree of edge
writeln(e, " has degree ", graph.degree(e));
}
}