|
GraphLab Project | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgraphlab.library.BaseGraph<VertexType,EdgeType>
graphlab.library.ListGraph<VertexType,EdgeType>
VertexType
- Type of the vertices the graph can work with.EdgeType
- Type of the edges the graph can work with.
toCheck : edgeIterator class, removeEdge, removeAllEdges, copy, setDirectedpublic class ListGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
Adjacency List Graph.
Field Summary |
---|
Fields inherited from class graphlab.library.BaseGraph |
---|
isSubgraph, lastSubgraphIndex, subgraphIndex, superGraph |
Constructor Summary | |
---|---|
ListGraph()
Constructs an undirected graph object that stores graph data using adjacency list data structure. |
|
ListGraph(BaseGraph<ImportVertexType,ImportEdgeType> graph,
GraphConverter<ImportVertexType,VertexType,ImportEdgeType,EdgeType,ImportGraphType,ListGraph<VertexType,EdgeType>> converter)
Constructs a graph object that stores graph data using adjacency list data structure by importing graph data from a pre-existing graph. |
|
ListGraph(boolean directed,
int expectedNumberOfVertices)
Constructs a graph object that stores graph data using adjacency list data structure. |
Method Summary | |
---|---|
void |
checkVertex(VertexType v)
If the supplied vertex is invalid (Not one of graph's vertices), throws InvalidVertexException. |
void |
clear()
Clears the graph. |
boolean |
containsVertex(VertexType v)
This method returns true if the graph contains the specified vertex, false otherwise. |
BaseGraph<VertexType,EdgeType> |
copy(EdgeVertexCopier<VertexType,EdgeType> gc)
Creates a clone of the current graph using the GraphConverter object which is responsible for duplication of the graph elements (edges and vertices). |
ListGraph<VertexType,EdgeType> |
createEmptyGraph()
Returns a new instance of an empty graph of the current graph type. |
void |
dump()
Prints the Adjacency Matrix to the standard output. |
java.util.Iterator<EdgeType> |
edgeIterator()
Constructs and returns an Edge Iterator object which iterates through all the edges in the graph. |
java.util.Iterator<EdgeType> |
edgeIterator(VertexType v)
Constructs an Edge Iterator object which iterates through all the edges going to or coming from the specified vertex v . |
Matrix |
getAdjacencyMatrix()
Returns a Jama Matrix object that represents adjacency matrix of the graph. |
VertexType |
getAVertex()
|
int[][] |
getEdgeArray()
Returns array of array of 'int's where represents a simple adjacency list. |
java.util.AbstractList<EdgeType> |
getEdges(VertexType source,
VertexType target)
Returns a collection of all edges which connects two vertices supplied as first and second arguments of this method. |
int |
getEdgesCount()
|
int |
getInDegree(VertexType v)
Returns in-degree of vertex vertexId, the number of edges which their target goes to the specified vertex. |
int |
getOutDegree(VertexType v)
Returns out-degree of the supplied vertex, the number of edges which their source is attached to the specified vertex. |
BaseVertex[] |
getVertexArray()
Returns array of vertices upcasted to BaseVertex. |
int |
getVerticesCount()
Returns the number of vertices. |
void |
insertEdge(EdgeType newEdge)
Inserts an edge in the graph. |
void |
insertVertex(VertexType newVertex)
Inserts a new vertex to the graph. |
boolean |
isDirected()
Returns whether the graph is directed. |
boolean |
isEdge(VertexType source,
VertexType target)
Returns true if there is an edge between specified vertices (direction considered for directed graphs). |
java.util.Iterator<VertexType> |
iterator()
Returns iterator object for the vertices. |
java.util.Iterator<EdgeType> |
lightEdgeIterator()
Returns a light(weight) Edge Iterator object which iterates through all the edges in the graph. |
java.util.Iterator<EdgeType> |
lightEdgeIterator(VertexType v)
Constructs a light(weight) Edge Iterator object which iterates through all the edges going to or coming from the specified vertex v . |
void |
removeAllEdges(VertexType source,
VertexType target)
Removes all edges between two vertices. |
void |
removeEdge(EdgeType edge)
Removes an edge from the graph. |
void |
removeVertex(VertexType v)
Removes a vertex and all it's connected edges. |
void |
setDirected(boolean directed)
|
protected void |
setId(VertexType v,
int id)
A wrapper for setting vertex Id's which supports multiple vertex owners. |
Methods inherited from class graphlab.library.BaseGraph |
---|
edges, getDegree, getEdges, getId, getNeighbors, getNewSubgraphIndex, registerSubgraph, setSubGraphIndex, vertices |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ListGraph(boolean directed, int expectedNumberOfVertices)
directed
- Indicated whether the graph is directed.expectedNumberOfVertices
- Approximate number of vertices that will be
added to the graph. This paramether is optional and is available for performance
reasons.public ListGraph()
public ListGraph(BaseGraph<ImportVertexType,ImportEdgeType> graph, GraphConverter<ImportVertexType,VertexType,ImportEdgeType,EdgeType,ImportGraphType,ListGraph<VertexType,EdgeType>> converter) throws InvalidGraphException
ImportVertexType
- The type of vertex object which the input graph contain.ImportEdgeType
- The type of edge object which the input graph contain.graph
- converter
- A GraphConverter object which is responsible for duplicating/converting graph
elements.
InvalidGraphException
- Throws when the input graph is an invalid graph object.Method Detail |
---|
protected void setId(VertexType v, int id)
v
- Vertex which the caller intends to set its Id.public int getVerticesCount()
BaseGraph
getVerticesCount
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
public java.util.Iterator<EdgeType> edgeIterator()
BaseGraph
edgeIterator
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
BaseGraph.lightEdgeIterator()
public java.util.Iterator<EdgeType> edgeIterator(VertexType v) throws InvalidVertexException
BaseGraph
v
.
Note that if the graph object is changed during iteration, the iteration may not
actually represent current state of the graph. For example, if you deleted an edge
after construction of this object, the edge would be included in the iteration.
edgeIterator
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
v
- Source or target of desired edges.
InvalidVertexException
BaseGraph.lightEdgeIterator(BaseVertex)
,
BaseGraph.getNeighbors(BaseVertex)
public java.util.Iterator<EdgeType> lightEdgeIterator()
BaseGraph
lightEdgeIterator
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
public java.util.Iterator<EdgeType> lightEdgeIterator(VertexType v) throws InvalidVertexException
BaseGraph
v
.
The light(weight) edge iterator presents an iterator with O(1) constructor. Note that you should
not change the content of the graph during your iteration. You can still change properties of
each edge or vertex.
lightEdgeIterator
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
v
- Source or target of desired edges.
InvalidVertexException
public void insertEdge(EdgeType newEdge) throws InvalidVertexException
BaseGraph
insertEdge
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
newEdge
- Reference to the new edge object.
InvalidVertexException
- Thrown when the edge object tries
to connect two vertices whom their indexes are invalid.public void insertVertex(VertexType newVertex)
BaseGraph
insertVertex
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
newVertex
- The new vertex to be inserted.public java.util.Iterator<VertexType> iterator()
BaseGraph
iterator
in interface java.lang.Iterable<VertexType extends BaseVertex>
iterator
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
public Matrix getAdjacencyMatrix()
BaseGraph
getAdjacencyMatrix
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
public boolean isDirected()
BaseGraph
isDirected
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
public void dump()
BaseGraph
dump
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
public void removeAllEdges(VertexType source, VertexType target) throws InvalidVertexException
BaseGraph
removeAllEdges
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
source
- Index of the edges' start point.target
- Index of the edges' end point.
InvalidVertexException
- Thrown when two supplied indexes of vertices are invalid.public void removeEdge(EdgeType edge) throws InvalidEdgeException
BaseGraph
removeEdge
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
edge
- Edge to be removed.
InvalidEdgeException
- If edge
is an invalid edge object.public java.util.AbstractList<EdgeType> getEdges(VertexType source, VertexType target) throws InvalidVertexException
BaseGraph
getEdges
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
InvalidVertexException
- if supplied source or target are invalid.public void removeVertex(VertexType v) throws InvalidVertexException
BaseGraph
removeVertex
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
InvalidVertexException
public int getInDegree(VertexType v) throws InvalidVertexException
BaseGraph
getInDegree
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
InvalidVertexException
BaseGraph.getDegree(BaseVertex)
public int getOutDegree(VertexType v) throws InvalidVertexException
BaseGraph
getOutDegree
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
InvalidVertexException
BaseGraph.getDegree(BaseVertex)
public BaseGraph<VertexType,EdgeType> copy(EdgeVertexCopier<VertexType,EdgeType> gc) throws InvalidGraphException
BaseGraph
copy
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
gc
- Reference to EdgeVertexCopier object.
InvalidGraphException
- If the graph is not a valid graph object.public VertexType getAVertex()
public boolean containsVertex(VertexType v)
BaseGraph
containsVertex
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
v
- Vertex to check existance.
public void checkVertex(VertexType v) throws InvalidVertexException
BaseGraph
checkVertex
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
v
- The vertex to be checked.
InvalidVertexException
- If the supplied vertex is invalid.public boolean isEdge(VertexType source, VertexType target) throws InvalidVertexException
BaseGraph
isEdge
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
InvalidVertexException
- if supplied source or target are invalid.public ListGraph<VertexType,EdgeType> createEmptyGraph()
BaseGraph
createEmptyGraph
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
public void setDirected(boolean directed)
setDirected
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
public BaseVertex[] getVertexArray()
BaseGraph
getVertexArray
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
public int[][] getEdgeArray()
BaseGraph
getEdgeArray
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
public void clear()
BaseGraph
clear
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
public int getEdgesCount()
getEdgesCount
in class BaseGraph<VertexType extends BaseVertex,EdgeType extends BaseEdge<VertexType>>
|
GraphLab Project | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |