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 Node newnode = new Node();
44 // making nodes (we create a table)
45 if (verbose) System.out.println("making nodes (tables in orig. version)");
46 Node[] hTable = newnode.fillTable(numNodes, numDegree, r);
47 Node[] eTable = newnode.fillTable(numNodes, numDegree, r);
50 if (verbose) System.out.println("updating from and coeffs");
51 for(int i = 0; i< numNodes; i++) {
53 n.makeUniqueNeighbors(eTable, r);
56 for (int i = 0; i < numNodes; i++) {
58 n.makeUniqueNeighbors(hTable, r);
61 // Create the fromNodes and coeff field
62 if (verbose) System.out.println("filling from fields");
63 for(int i = 0; i< numNodes; i++) {
68 for (int i = 0; i < numNodes; i++) {
73 // Update the fromNodes
74 for (int i = 0; i < numNodes; i++) {
78 for (int i = 0; i < numNodes; i++) {
83 BiGraph g = new BiGraph(eTable[0], hTable[0]);
88 * Update the field values of e-nodes based on the values of
89 * neighboring h-nodes and vice-versa.
110 * Override the toString method to print out the values of the e and h nodes.
111 * @return a string contain the values of the e and h nodes.
113 public String toString()
115 StringBuffer retval = new StringBuffer();
119 retval.append("E: " + n + "\n");
125 retval.append("H: " + n + "\n");
128 return retval.toString();