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.
11 * Nodes that represent the electrical field.
15 * Nodes that representhe the magnetic field.
20 * Construct the bipartite graph.
21 * @param e the nodes representing the electric fields
22 * @param h the nodes representing the magnetic fields
24 BiGraph(Node[] e, Node[] h)
31 * Create the bi graph that contains the linked list of
33 * @param numNodes the number of nodes to create
34 * @param numDegree the out-degree of each node
35 * @param verbose should we print out runtime messages
36 * @return the bi graph that we've created.
39 static BiGraph create(int numNodes, int degree, boolean verbose, Random r)
41 // making nodes (we create a table)
42 //if (verbose) System.printString("making nodes (tables in orig. version)");
43 //Node [] eTable=Node.fillTable(numNodes, numDegree, r);
44 //Node [] hTable=Node.fillTable(numNodes, numDegree, r);
46 Node [] eTable = global new Node[numNodes];
47 Node [] hTable = global new Node[numNodes];
49 eTable[0] = global new Node(degree, r);
50 hTable[0] = global new Node(degree, r);
52 BiGraph g = global new BiGraph(eTable, hTable);
63 public void allocate( int indexBegin, int indexEnd, int degree, Random r )
65 Node prevNodeE = global new Node(degree, r);
66 Node prevNodeH = global new Node(degree, r);
68 eNodes[indexBegin] = prevNodeE;
69 hNodes[indexBegin] = prevNodeH;
71 for( int i = indexBegin + 1; i < indexEnd; i++ ) {
72 Node curNodeE = global new Node(degree, r);
73 Node curNodeH = global new Node(degree, r);
78 prevNodeE.next = curNodeE;
79 prevNodeH.next = curNodeH;
87 public void linkSegments( int index ) {
88 eNodes[index - 1].next = eNodes[index];
89 hNodes[index - 1].next = hNodes[index];
98 public void makeNeighbors( int indexBegin, int indexEnd, Random r )
100 //System.printString( "Making unique neighbors for hNodes...\n" );
103 //if (verbose) System.printString("updating from and coeffs");
104 for(int i = indexBegin; i < indexEnd; i++) {
106 n.makeUniqueNeighbors(eNodes, r);
109 //System.printString( "Making unique neighbors for eNodes...\n" );
111 for (int i = indexBegin; i < indexEnd; i++) {
113 n.makeUniqueNeighbors(hNodes, r);
118 public void makeFromNodes( int indexBegin, int indexEnd )
120 //System.printString( "Making h fromNodes...\n" );
122 // Create the fromNodes and coeff field
123 //if (verbose) System.printString("filling from fields");
124 for(int i = indexBegin; i < indexEnd; i++) {
129 //System.printString( "Making e fromNodes...\n" );
131 for(int i = indexBegin; i < indexEnd; i++) {
138 public void makeFromLinks( int indexBegin, int indexEnd, Random r )
140 //System.printString( "Updating h fromNodes...\n" );
142 // Update the fromNodes
143 for(int i = indexBegin; i < indexEnd; i++) {
145 n.updateFromNodes(r);
148 //System.printString( "Updating e fromNodes...\n" );
150 for(int i = indexBegin; i < indexEnd; i++) {
152 n.updateFromNodes(r);
158 * Override the toString method to print out the values of the e and h nodes.
159 * @return a string contain the values of the e and h nodes.
161 public String toString()
163 StringBuffer retval = new StringBuffer();
164 Node tmp = eNodes[0];
167 retval.append("E: " + n + "\n");
173 retval.append("H: " + n + "\n");
176 return retval.toString();