2 * A class that represents the irregular bipartite graph used in
3 * EM3D. The graph contains two linked structures that represent the
4 * E nodes and the N nodes in the application.
10 * Nodes that represent the electrical field.
14 * Nodes that representhe the magnetic field.
18 EVector [][] reversetable;
22 * Construct the bipartite graph.
23 * @param e the nodes representing the electric fields
24 * @param h the nodes representing the magnetic fields
26 BiGraph(Node[] e, Node[] h) {
32 * Create the bi graph that contains the linked list of
34 * @param numNodes the number of nodes to create
35 * @param numDegree the out-degree of each node
36 * @param verbose should we print out runtime messages
37 * @return the bi graph that we've created.
40 static BiGraph create(int numNodes, int degree, int numThreads) {
41 // making nodes (we create a table)
42 Node [] eTable = global new Node[numNodes];
43 Node [] hTable = global new Node[numNodes];
44 BiGraph g = global new BiGraph(eTable, hTable);
46 g.reversetable=global new EVector[numThreads][];
56 public void allocateNodes( int indexBegin, int indexEnd, int threadIndex) {
57 for(int i = indexBegin; i < indexEnd; i++ ) {
58 eNodes[i]=global new Node();
59 hNodes[i]=global new Node();
61 reversetable[threadIndex]=global new EVector[numNodes];
64 public void initializeNodes(Node[] fromnodes, Node[] tonodes, int begin, int end, int degree, Random r, int threadIndex) {
65 for(int i = begin; i < end; i++ ) {
67 n.init(degree, r.nextDouble());
68 n.makeUniqueNeighbors(reversetable[threadIndex], tonodes, r, begin, end);
78 public void makeFromNodes(Node[] nodes, int indexBegin, int indexEnd, Random r) {
79 // Create the fromNodes and coeff field
80 int numthreads=reversetable.length;
81 for(int i = indexBegin; i < indexEnd; i++) {
84 for(int j=0;j<numthreads;j++) {
85 EVector v=reversetable[j][i];
90 n.fromNodes=global new Node[count];
91 n.coeffs=global new double[count];
93 for(int j=0;j<numthreads;j++) {
94 EVector v=reversetable[j][i];
96 for(int k=0;k<v.size();k++) {
97 n.fromNodes[count]=(Node)v.elementAt(k);
98 n.coeffs[count++]=r.nextDouble();