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 [][] ereversetable;
19 EVector [][] hreversetable;
23 * Construct the bipartite graph.
24 * @param e the nodes representing the electric fields
25 * @param h the nodes representing the magnetic fields
27 BiGraph(Node[] e, Node[] h) {
33 * Create the bi graph that contains the linked list of
35 * @param numNodes the number of nodes to create
36 * @param numDegree the out-degree of each node
37 * @param verbose should we print out runtime messages
38 * @return the bi graph that we've created.
41 static BiGraph create(int numNodes, int degree, int numThreads) {
42 // making nodes (we create a table)
43 Node [] eTable = new Node[numNodes];
44 Node [] hTable = new Node[numNodes];
45 BiGraph g = new BiGraph(eTable, hTable);
47 g.ereversetable=new EVector[numThreads][];
48 g.hreversetable=new EVector[numThreads][];
58 public void allocateNodes( int indexBegin, int indexEnd, int threadIndex) {
59 for(int i = indexBegin; i < indexEnd; i++ ) {
63 ereversetable[threadIndex]=new EVector[numNodes];
64 hreversetable[threadIndex]=new EVector[numNodes];
67 public void initializeNodes(Node[] fromnodes, Node[] tonodes, EVector[][] reversetable, int begin, int end, int degree, Random r, int threadIndex) {
68 for(int i = begin; i < end; i++ ) {
70 n.init(degree, r.nextDouble());
71 n.makeUniqueNeighbors(reversetable[threadIndex], tonodes, r, begin, end);
81 public void makeFromNodes(Node[] nodes, EVector reversetable[][], int indexBegin, int indexEnd, Random r) {
82 // Create the fromNodes and coeff field
83 int numthreads=reversetable.length;
84 for(int i = indexBegin; i < indexEnd; i++) {
87 for(int j=0;j<numthreads;j++) {
88 EVector v=reversetable[j][i];
93 n.fromNodes=new Node[count];
94 n.coeffs=new double[count];
96 for(int j=0;j<numthreads;j++) {
97 EVector v=reversetable[j][i];
99 for(int k=0;k<v.size();k++) {
100 n.fromNodes[count]=(Node)v.elementAt(k);
101 n.coeffs[count++]=r.nextDouble();