Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uchicago.src.sim.network
Class NetworkFactory

    java.lang.Object
      uchicago.src.sim.network.NetworkFactory

All Implemented Interfaces:
  NetworkConstants

    public class NetworkFactory

extends java.lang.Object
implements NetworkConstants

Creates a list of nodes with their links from various sources. Note: this class is not thread safe.

Version:
  $Revision: 1.14 $ $Date: 2004/11/03 19:51:01 $
Author:
  Nick Collier

Field Summary

Fields inherited from interface uchicago.src.sim.network.NetworkConstants
`ASCII, BINARY, DL, EXCEL, LARGE, SMALL`

Method Summary
`static java.util.List` | `createRandomDensityNetwork(int size, double density, boolean allowLoops, boolean isSymmetric, java.lang.Class nodeClass, java.lang.Class edgeClass)` Creates a RandomDensityNetwork.
`static java.util.List` | `createSquareLatticeNetwork(int cols, int rows, boolean wrapAround, int connectRadius, java.lang.Class node, java.lang.Class edge)` Creates a square lattice network.
`static java.util.List` | `createUnlinkedNetwork(int numNodes, java.lang.Class nodeClass)` Creates a list containing the specified number of nodes of the specified type.
`static java.util.List` | `createWattsStrogatzNetwork(int size, int connectRadius, double rewireProb, java.lang.Class node, java.lang.Class edge)` Creates a classic W-S network small world network (ring substrate).
`static java.util.List` | `getDLNetworkFromStream(java.io.InputStream stream, java.lang.Class nodeClass, java.lang.Class edgeClass, int matrixType)` Creates a List of nodes (and their edges) from the specified InputStream.
`static java.util.List` | `getNetwork(java.lang.String fileName, int fileFormat, java.lang.Class nodeClass, java.lang.Class edgeClass)` Deprecated. use `NetworkFactory(String, int, Class, Class, int)` instead.
`static java.util.List` | `getNetwork(java.lang.String fileName, int fileFormat, java.lang.Class nodeClass, java.lang.Class edgeClass, int matrixType)` Creates a List of nodes (and their edges) from the specified file.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getNetwork

    public static java.util.List getNetwork(java.lang.String fileName,
                                            int fileFormat,
                                            java.lang.Class nodeClass,
                                            java.lang.Class edgeClass,
                                            int matrixType)

  Creates a List of nodes (and their edges) from the specified file. The returned Nodes will be of the type specified by nodeClass and the edges of type edgeClass. The class nodeClass must implement the Node interface and the class edgeClass much implement the Edge interface. Supported formats are NetworkFactor.DL, and NetworkFactor.EXCEL.

  The matrix is assumed to be square for both the dl and Excel formats. For Excel, each worksheet is treated as a matrix, and any worksheets that do not contain matrices will cause an error. The worksheet name is treated as the matrix label unless the name begins with Sheet (Excel's generic worksheet name). The format for excel files is that imported and exported by UCINet. The first cell is empty, and the node labels begin on this first row in the second column. The column node labels begin in first column on the second row. The actual data begins in cell 2,2. For example, ``

                    | first_label | second_label | ...
       -------------+-------------+--------------+----
       first_label  | 0           | 1            | ...
       -------------+-------------+--------------+----
       second_label | 1           | 0            | ...
       -------------+-------------+--------------+----
       ...          | ...         | ...          | ...

  If the matrix has no node labels, RePast will expect the first row and column to be blank and as before, for the data to begin in cell 2,2.

  The matrixType parameter refers to the size of the matrix elements, the ij values. A matrix of type of NetworkConstants.BINARY contains on 0 or 1 as elements. A matrix of type of NetworkConstants.SMALL contains values of -127 - 127 as elements. And a matrix of type NetworkConstants.LARGE contains anything else.

  Parameters:
    `fileName` - the name of the file
    `fileFormat` - the format of the file (NetworkFactory.DL and NetworkFactory.EXCEL)
    `nodeClass` - specifies the class of the created nodes
    `edgeClass` - specified the class of the created edges
    `matrixType` - the type of the matrix. type refers to the size of the matrix elements (ij values) and can be one of NetworkConstants.BINARY, NetworkConstants.LARGE, NetworkConstants.SMALL

### getDLNetworkFromStream

    public static java.util.List getDLNetworkFromStream(java.io.InputStream stream,
                                                        java.lang.Class nodeClass,
                                                        java.lang.Class edgeClass,
                                                        int matrixType)

  Creates a List of nodes (and their edges) from the specified InputStream. The returned Nodes will be of the type specified by nodeClass and the edges of type edgeClass. The class nodeClass must implement the Node interface and the class edgeClass much implement the Edge interface. This assumes that the source of the stream is in DL format. The matrix is assumed to be square.

  The matrixType parameter refers to the size of the matrix elements, the ij values. A matrix of type of NetworkConstants.BINARY contains on 0 or 1 as elements. A matrix of type of NetworkConstants.SMALL contains values of -127 - 127 as elements. And a matrix of type NetworkConstants.LARGE contains anything else.

  Parameters:
    `stream` - the InputStream to read the data from.
    `nodeClass` - specifies the class of the created nodes
    `edgeClass` - specified the class of the created edges
    `matrixType` - the type of the matrix. type refers to the size of the matrix elements (ij values) and can be one of NetworkConstants.BINARY, NetworkConstants.LARGE, NetworkConstants.SMALL

### getNetwork

    public static java.util.List getNetwork(java.lang.String fileName,
                                            int fileFormat,
                                            java.lang.Class nodeClass,
                                            java.lang.Class edgeClass)

  Deprecated. use `NetworkFactory(String, int, Class, Class, int)` instead.

  Creates a List of nodes (and their edges) from the specified file. The returned Nodes will be of the type specified by nodeClass and the edges of type edgeClass. The class nodeClass must implement the Node interface and the class edgeClass much implement the Edge interface. Supported formats are NetworkFactor.DL, and NetworkFactor.EXCEL.

  The matrix is assumed to be square for both the dl and Excel formats. For Excel, each worksheet is treated as a matrix, and any worksheets that do not contain matrices will cause an error. The worksheet name is treated as the matrix label unless the name begins with Sheet (Excel's generic worksheet name). The format for excel files is that imported and exported by UCINet. The first cell is empty, and the node labels begin on this first row in the second column. The column node labels begin in first column on the second row. The actual data begins in cell 2,2. For example, ``

                    | first_label | second_label | ...
       -------------+-------------+--------------+----
       first_label  | 0           | 1            | ...
       -------------+-------------+--------------+----
       second_label | 1           | 0            | ...
       -------------+-------------+--------------+----
       ...          | ...         | ...          | ...

  If the matrix has no node labels, RePast will expect the first row and column to be blank and as before, for the data to begin in cell 2,2.

  Parameters:
    `fileName` - the name of the file
    `fileFormat` - the format of the file (NetworkFactory.DL and NetworkFactory.EXCEL)
    `nodeClass` - specifies the class of the created nodes
    `edgeClass` - specified the class of the created edges

### createUnlinkedNetwork

    public static java.util.List createUnlinkedNetwork(int numNodes,
                                                       java.lang.Class nodeClass)

  Creates a list containing the specified number of nodes of the specified type. The nodes are unlinked.

### createSquareLatticeNetwork

    public static java.util.List createSquareLatticeNetwork(int cols,
                                                            int rows,
                                                            boolean wrapAround,
                                                            int connectRadius,
                                                            java.lang.Class node,
                                                            java.lang.Class edge)

  Creates a square lattice network. MORE DOCS NEEDED HERE!!!

  Parameters:
    `cols` - the number of columns in the network
    `rows` - the number of rows in the network
    `wrapAround` - whether the links should wrap around the lattice
    `connectRadius` - the connect radius of the network
    `node` - the class to create the network nodes from
    `edge` - the class to create the network edges from

### createRandomDensityNetwork

    public static java.util.List createRandomDensityNetwork(int size,
                                                            double density,
                                                            boolean allowLoops,
                                                            boolean isSymmetric,
                                                            java.lang.Class nodeClass,
                                                            java.lang.Class edgeClass)

  Creates a RandomDensityNetwork. The network will have a density. (ratio of # of existing edges to the maximum possible # of edges) approximately equal to a specified double density. The network is created by looping over all i, j node pairs and deciding on the existence of a link between the nodes by comparing the value of density to a uniform random number. If the boolean allowLoops is false, no self loops (links from i to itself) will be permitted. If the boolean isSymmetric is true, all ties will be bidirectional (i -> j = j -> i). This is what is generally referred to in the network literature as "random" network - a class of networks which have been well studied analytically, but which are structurally quite unlike most empirically observed "social" networks.

  Parameters:
    `size` - the size of the network (number of nodes)
    `allowLoops` - whether self loops are allowed
    `isSymmetric` - whether the resulting network is to be symmetric
    `nodeClass` - the class for the network nodes
    `edgeClass` - the class for the network edges

### createWattsStrogatzNetwork

    public static java.util.List createWattsStrogatzNetwork(int size,
                                                            int connectRadius,
                                                            double rewireProb,
                                                            java.lang.Class node,
                                                            java.lang.Class edge)

  Creates a classic W-S network small world network (ring substrate).

  Note that when connectRadius is > 1 there can be funny effects if the number of nodes is not a multiple of the radius. If it doesn't divide evenly, this leaves out the extra links.

  Parameters:
    `size` - the size (number of nodes) in the network
    `connectRadius` - the connect radius of the network.
    `rewireProb` - the edge rewire probability
    `node` - the class to create the nodes from
    `edge` - the class to create the edges from

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD