utilities
Class GraphIO

java.lang.Object
  |
  +--utilities.GraphIO

public class GraphIO
extends java.lang.Object

A class for importing and exporting graph object into Individuals

Author:
Kevin Zollman

Constructor Summary
GraphIO()
           
 
Method Summary
static Individual[] adjacencyMatrix(int[][] m)
          Turns an adjacency matrix into a collection of Individuals.
static java.util.HashSet readJobsFile(java.lang.String fn)
          A function to read jobs files.
static int[][] stringMatrix(java.lang.String s)
          A function to turn a string representing an adjacency matrix into an integer matrix.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphIO

public GraphIO()
Method Detail

readJobsFile

public static java.util.HashSet readJobsFile(java.lang.String fn)
                                      throws ModelError,
                                             java.io.FileNotFoundException,
                                             java.io.IOException
A function to read jobs files. A jobs file is structured as follows:
The job id
The job description string
A graph adjacency matrix
repeat
This is read in by this function and a HashSet of Jobs objects are returned.

Parameters:
fn - The file name of the jobs file
Returns:
A HashSet of Jobs objects read from the jobs file.
ModelError
java.io.FileNotFoundException
java.io.IOException

stringMatrix

public static int[][] stringMatrix(java.lang.String s)
                            throws ModelError
A function to turn a string representing an adjacency matrix into an integer matrix. THIS IS NOT A GENERALIZED UTILITY, it expects to get one two dimenstional matrix of single digit integers. Anything else will screw it up.

Parameters:
s - The string to be processed
Returns:
A two dimensional integer matrix processed from the string
ModelError

adjacencyMatrix

public static Individual[] adjacencyMatrix(int[][] m)
Turns an adjacency matrix into a collection of Individuals. This function does not allow self connections regardless of what the adjacency matrix says. For the matrix, 0 means no connection greater than 0 means a connection. No weightings or anything.

Parameters:
m - The adjacency matrix
Returns:
A collection of individuals who are interconnected according to the matrix