com.intel.hadoop.graphbuilder.graph.glgraph
Class GLGraph<VidType,VertexData,EdgeData>

java.lang.Object
  extended by com.intel.hadoop.graphbuilder.graph.glgraph.GLGraph<VidType,VertexData,EdgeData>
Type Parameters:
VidType -
VertexData -
EdgeData -
All Implemented Interfaces:
Graph<VidType,VertexData,EdgeData>

public class GLGraph<VidType,VertexData,EdgeData>
extends java.lang.Object
implements Graph<VidType,VertexData,EdgeData>

This is equivalent to GraphLab2 distributed graph ://code.google.com /p/graphlabapi/source/browse/src/graphlab/graph/distributed_graph.hpp. Most of the implementation is identical to the C++ version in GraphLab2. Besides the "set" methods defined in the Graph interface, this class also provides "get" methods iterate over the incoming/outgoing edge list of a given vertex.


Constructor Summary
GLGraph()
           
 
Method Summary
 void addEdge(VidType source, VidType target, EdgeData edata)
          Add a single edge to the graph.
 void addEdges(java.util.List<VidType> sources, java.util.List<VidType> targets, java.util.List<EdgeData> edata)
          Batch add a collection of edges to the graph.
 void addVertexRecord(VertexRecord<VidType,VertexData> vrecord)
          Add a vertex record to the graph.
 java.util.List<java.lang.Integer> c2rMap()
           
 void clear()
          Reset the graph to its initial empty state.
 SparseGraphStruct csc()
           
 SparseGraphStruct csr()
           
 java.util.List<EdgeData> edatalist()
           
 EdgeData edgeData(EdgeType e)
           
 void finalize()
          This method shall be called to ensure that the graph is in its finalized state and is ready for output.
 EdgeList inEdges(int vid)
           
 int lvid(VidType gvid)
           
 int numEdges()
           
 int numInEdges(int vid)
           
 int numOutEdges(int vid)
           
 int numVertices()
           
 EdgeList outEdges(int vid)
           
 int pid()
           
 void reserveEdgeSpace(int numEdges)
           
 void reserveVertexSpace(int numVertices)
           
 EdgeData setEdgeData(EdgeType e, EdgeData value)
           
 void setPid(int pid)
           
 java.lang.String toString()
           
 java.util.Map<VidType,java.lang.Integer> vid2lvid()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GLGraph

public GLGraph()
Method Detail

numEdges

public int numEdges()
Specified by:
numEdges in interface Graph<VidType,VertexData,EdgeData>
Returns:
number of edges in the graph.

edgeData

public EdgeData edgeData(EdgeType e)
Parameters:
e - A lazy edge object.
Returns:
the edge data of EdgeType e.

setEdgeData

public EdgeData setEdgeData(EdgeType e,
                            EdgeData value)
Parameters:
e - The lazy edge object.
value - the new edge data.
Returns:
the new edge data of EdgeType e.

lvid

public int lvid(VidType gvid)
Parameters:
gvid - the global id of the vertex
Returns:
The local vertex id of a vertex in this graph partition.

numInEdges

public int numInEdges(int vid)
Parameters:
vid - the local vertex id.
Returns:
Number of incoming edges of the vertex in this graph partition, NOT in the global graph.

numOutEdges

public int numOutEdges(int vid)
Parameters:
vid - the local vertex id.
Returns:
Number of outgoing edges of the vertex in this graph partition, NOT in the global graph.

reserveEdgeSpace

public void reserveEdgeSpace(int numEdges)
Specified by:
reserveEdgeSpace in interface Graph<VidType,VertexData,EdgeData>
Parameters:
numEdges - expected number of edges in the graph.

reserveVertexSpace

public void reserveVertexSpace(int numVertices)
Specified by:
reserveVertexSpace in interface Graph<VidType,VertexData,EdgeData>
Parameters:
numVertices - expected number of vertices in the graph.

pid

public int pid()
Specified by:
pid in interface Graph<VidType,VertexData,EdgeData>
Returns:
partition id of this graph.

setPid

public void setPid(int pid)
Specified by:
setPid in interface Graph<VidType,VertexData,EdgeData>
Parameters:
pid - partition id of this graph.

numVertices

public int numVertices()
Specified by:
numVertices in interface Graph<VidType,VertexData,EdgeData>
Returns:
number of vertices in the graph.

addEdges

public void addEdges(java.util.List<VidType> sources,
                     java.util.List<VidType> targets,
                     java.util.List<EdgeData> edata)
Description copied from interface: Graph
Batch add a collection of edges to the graph.

Specified by:
addEdges in interface Graph<VidType,VertexData,EdgeData>
Parameters:
sources - List of source vertex ids.
targets - List of target vertex ids.
edata - List of edge data.

addEdge

public void addEdge(VidType source,
                    VidType target,
                    EdgeData edata)
Description copied from interface: Graph
Add a single edge to the graph.

Specified by:
addEdge in interface Graph<VidType,VertexData,EdgeData>
Parameters:
source - the source vertex id of the edge to be added.
target - the target vertex id of the edge to be added.
edata - the edge data of the edge to be added.

addVertexRecord

public void addVertexRecord(VertexRecord<VidType,VertexData> vrecord)
Description copied from interface: Graph
Add a vertex record to the graph.

Specified by:
addVertexRecord in interface Graph<VidType,VertexData,EdgeData>
Parameters:
vrecord - the VertexRecord object to be added.
See Also:
VertexRecord

inEdges

public EdgeList inEdges(int vid)

outEdges

public EdgeList outEdges(int vid)

finalize

public void finalize()
              throws java.lang.Exception
Description copied from interface: Graph
This method shall be called to ensure that the graph is in its finalized state and is ready for output.

Specified by:
finalize in interface Graph<VidType,VertexData,EdgeData>
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Exception

vid2lvid

public java.util.Map<VidType,java.lang.Integer> vid2lvid()
Returns:
the map from global vid to local vid in this graph partition.

edatalist

public java.util.List<EdgeData> edatalist()
Returns:
a list of edgedata in this graph partition.

clear

public void clear()
Description copied from interface: Graph
Reset the graph to its initial empty state.

Specified by:
clear in interface Graph<VidType,VertexData,EdgeData>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

csr

public SparseGraphStruct csr()
Returns:
the CSR representation of the graph.

csc

public SparseGraphStruct csc()
Returns:
the CSC representation of the graph.

c2rMap

public java.util.List<java.lang.Integer> c2rMap()
Returns:
the edge index mapping from the CSC to CSR.