1 import java.util.Random;
3 * A class that represents the irregular bipartite graph used in
4 * EM3D. The graph contains two linked structures that represent the
5 * E nodes and the N nodes in the application.
12 * Nodes that represent the electrical field.
16 * Nodes that representhe the magnetic field.
21 * Construct the bipartite graph.
22 * @param e the nodes representing the electric fields
23 * @param h the nodes representing the magnetic fields
25 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 BiGraph create(int numNodes, int numDegree, boolean verbose, Random r)
42 // making nodes (we create a table)
43 if (verbose) System.out.println("making nodes (tables in orig. version)");
44 Node[] hTable = Node.fillTable(numNodes, numDegree, r);
45 Node[] eTable = Node.fillTable(numNodes, numDegree, r);
48 if (verbose) System.out.println("updating from and coeffs");
49 for(int i = 0; i< numNodes; i++) {
51 n.makeUniqueNeighbors(eTable, r);
54 for (int i = 0; i < numNodes; i++) {
56 n.makeUniqueNeighbors(hTable, r);
59 // Create the fromNodes and coeff field
60 if (verbose) System.out.println("filling from fields");
61 for(int i = 0; i< numNodes; i++) {
66 for (int i = 0; i < numNodes; i++) {
71 // Update the fromNodes
72 for (int i = 0; i < numNodes; i++) {
76 for (int i = 0; i < numNodes; i++) {
81 BiGraph g = new BiGraph(eTable[0], hTable[0]);
86 * Update the field values of e-nodes based on the values of
87 * neighboring h-nodes and vice-versa.
108 * Override the toString method to print out the values of the e and h nodes.
109 * @return a string contain the values of the e and h nodes.
111 public String toString()
113 StringBuffer retval = new StringBuffer();
117 retval.append("E: " + n + "\n");
123 retval.append("H: " + n + "\n");
126 return retval.toString();