com.intel.hadoop.graphbuilder.graph.simplegraph
Class SimpleGraph<VidType,VertexData,EdgeData>

java.lang.Object
  extended by com.intel.hadoop.graphbuilder.graph.simplegraph.SimpleGraph<VidType,VertexData,EdgeData>
Type Parameters:
VidType -
VertexData -
EdgeData -
All Implemented Interfaces:
Graph<VidType,VertexData,EdgeData>
Direct Known Subclasses:
SimpleSubGraph

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

This is a pre-finalized but post-partitioned adjacency format for GraphLab2. The local edges are stored in an adjacency list. The advantage of this representation lies in its simplicity, therefore easier to parallelize than GLGraph. Also, it leaves the heavy duty of GLGraph.finalize() to much more efficient C++ code on the GraphLab2 side.


Constructor Summary
SimpleGraph()
          Creates an empty graph.
 
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.
 void clear()
          Reset the graph to its initial empty state.
 void clearAdjList()
          Clear the adjacency list.
 void clearEdataList()
          Clear the edge data list.
 void finalize()
          This method shall be called to ensure that the graph is in its finalized state and is ready for output.
 int numEdges()
           
 int numVertices()
           
 java.util.List<EdgeData> outEdgeData(VidType v)
           
 java.util.List<VidType> outEdgeTargetIds(VidType v)
           
 int pid()
           
 void reserveEdgeSpace(int numEdges)
           
 void reserveVertexSpace(int numVertices)
           
 void setPid(int pid)
           
 java.lang.String toString()
           
 java.util.List<VidType> vertices()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleGraph

public SimpleGraph()
Creates an empty graph.

Method Detail

vertices

public java.util.List<VidType> vertices()
Returns:
a list of ids of the vertices in the graph partition.

outEdgeTargetIds

public java.util.List<VidType> outEdgeTargetIds(VidType v)
Parameters:
v - the source vertex of the edge list.
Returns:
an ordered list of vertices u where there is an edge from v -> u.

outEdgeData

public java.util.List<EdgeData> outEdgeData(VidType v)
Parameters:
v - the source vertex of the edge list.
Returns:
an ordered list of edge data of the outgoing edges of v.

clearEdataList

public void clearEdataList()
Clear the edge data list.


clearAdjList

public void clearAdjList()
Clear the adjacency list.


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.

numEdges

public int numEdges()
Specified by:
numEdges in interface Graph<VidType,VertexData,EdgeData>
Returns:
number of edges 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

finalize

public void finalize()
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

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