com.intel.hadoop.graphbuilder.graph.glgraph
Class SparseGraphStruct

java.lang.Object
  extended by com.intel.hadoop.graphbuilder.graph.glgraph.SparseGraphStruct

public class SparseGraphStruct
extends java.lang.Object

A dense data structure of a sparse matrix: (Compressed Sparse Row) ://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR_or_CRS .29. This class only represents the zero/non-zero structure of the matrix, and the actual entry data, if any, should be stored separately as a list elsewhere.


Constructor Summary
SparseGraphStruct(int n)
          Initialize a n by n empty matrix.
SparseGraphStruct(int numVertices, java.util.List<java.lang.Integer> sources, java.util.List<java.lang.Integer> targets)
          Initialize a n by n matrix, with entries encoded by a source array and target array.
 
Method Summary
 int begin(int row)
           
 void clear()
          Clear the matrix.
 int end(int row)
           
 java.util.List<java.lang.Integer> getColIndex()
           
 java.util.List<java.lang.Integer> getRowIndex()
           
 int numEdges()
           
 int numVertices()
           
 net.minidev.json.JSONObject toJSONObj()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparseGraphStruct

public SparseGraphStruct(int n)
Initialize a n by n empty matrix.

Parameters:
n - the size of the square matrix.

SparseGraphStruct

public SparseGraphStruct(int numVertices,
                         java.util.List<java.lang.Integer> sources,
                         java.util.List<java.lang.Integer> targets)
Initialize a n by n matrix, with entries encoded by a source array and target array.

Parameters:
n - the size of the square matrix.
sources - the list of source ids.
targets - the list of target ids.
Method Detail

numEdges

public int numEdges()
Returns:
the number of non-zero entries.

numVertices

public int numVertices()
Returns:
the dimension.

begin

public int begin(int row)
Parameters:
row -
Returns:
the begin column index of the non-zero entry of a given row index.

end

public int end(int row)
Parameters:
row -
Returns:
the end column index of the non-zero entry of a given row index.

clear

public void clear()
Clear the matrix.


getRowIndex

public java.util.List<java.lang.Integer> getRowIndex()
Returns:
the internal row representation.

getColIndex

public java.util.List<java.lang.Integer> getColIndex()
Returns:
the internal column representation.

toJSONObj

public net.minidev.json.JSONObject toJSONObj()
Returns:
the JSON encoding.