|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.dbreplicator.graph
Interface DGraph
- All Known Implementing Classes:
- DirectedGraph, JbDirectedGraph
public interface DGraph
A directed graph with weighted edges. The weights are non-negative. The directed graph can contain any object as a vertex. Null references are not allowed. A vertex can have a self loop, i. e. an edge that leaves from and enters the same vertex. There cannot be more than Integer.MAX_VALUE vertices in the directed graph. Removing vertices from the directed graph is not supported. The directed graph is not thread-safe: it must not be used concurrently by multiple threads.
The behavior of the directed graph is not specified if the value of an object is changed in a manner that affects comparisons by the equals(object) method while the object is a vertex in the graph. It is prohibited for a directed graph to contain itself as a vertex.
| Method Summary | |
|---|---|
boolean |
addEdge(java.lang.Object first,
java.lang.Object second,
int weight)
Adds an edge of a specified weight from the vertex first to the vertex second. |
boolean |
addVertex(java.lang.Object object)
Adds the specified vertex to this directed graph if the vertex is not null and the vertex is not already present in this directed graph. |
java.lang.Object[] |
adjacentsOf(java.lang.Object ob)
Returns an array containing all vertices that are adjacent to the specified vertex. |
int |
edgeCount()
Returns the number of edges in this directed graph. |
int |
edgeWeight()
Returns the sum of the weights of all edges in this directed graph. |
int |
edgeWeight(java.lang.Object first,
java.lang.Object second)
Returns the weight of the edge that leaves from the vertex first and enters the vertex second. |
boolean |
equals(java.lang.Object obj)
|
boolean |
hasCycle()
Returns true if there is a cycle in the directed graph. |
boolean |
hasEdge(java.lang.Object first,
java.lang.Object second)
Returns true if this directed graph contains an edge that leaves from the vertex first and enters the vertex second. |
boolean |
hasEdges()
Returns true if there are edges in this directed graph. |
int |
hashCode()
Returns the hash code value for this directed graph. |
boolean |
hasVertex(java.lang.Object ob)
Returns true if this directed graph contains the specified vertex. |
boolean |
hasVertices()
|
int |
inDegree(java.lang.Object object)
Returns the number of edges that enter the specified vertex. |
boolean |
isIsolated(java.lang.Object ob)
Returns true if the specified vertex is isolated. |
boolean |
isLinearList()
Returns true if the directed graph forms a linear list. |
int |
outDegree(java.lang.Object vertex)
Returns the number of edges that leave from the specified vertex. |
java.lang.Object[] |
topologicalSort()
Returns an array of all of the vertices in this directed graph in some topological sort order. |
int |
vertexCount()
Returns the number of vertices in this directed graph. |
java.lang.Object[] |
verticesToArray()
Returns an array containing all vertices in this directed graph. |
| Method Detail |
|---|
equals
boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
hashCode
int hashCode()
- Returns the hash code value for this directed graph. The hash code of a
directed graph is defined to be the sum of the hash codes of the vertices
in the directed graph. The sum is allowed to overflow if needed. This
definition ensures that if
s1.equals(s2)thens1.hashCode() == s2.hashCode()for any two directed graphss1ands2, as required by the general contract of the java.lang.Object.hashCode method.- Overrides:
hashCodein classjava.lang.Object
addVertex
boolean addVertex(java.lang.Object object) throws RepException
- Adds the specified vertex to this directed graph if the vertex is not
null and the vertex is not already present in this directed graph. More
formally, adds the specified vertex
objto this directed graph ifobj != nulland this directed graph contains no vertexesuch thatobj.equals(e). The number of vertices in this directed graph may not exceed Integer.MAX_VALUE.- Throws:
RepException
hasVertex
boolean hasVertex(java.lang.Object ob)
- Returns true if this directed graph contains the specified
vertex. More formally, returns true if and only if
obj != nulland this directed graph contains an vertexesuch thatobj.equals(e).
hasVertices
boolean hasVertices()
vertexCount
int vertexCount()
- Returns the number of vertices in this directed graph.
verticesToArray
java.lang.Object[] verticesToArray()
- Returns an array containing all vertices in this directed graph. The
vertices need not be in any special order.
The returned array will be "safe" in that no references to it are maintained by this directed graph. In other words, this method must allocate a new array even if this collection is backed by an array. The caller is thus free to modify the returned array.
- Returns:
- an array containing all vertices in this directed graph.
addEdge
boolean addEdge(java.lang.Object first, java.lang.Object second, int weight) throws RepException
- Adds an edge of a specified weight from the vertex first to the
vertex second.
- Throws:
RepException
hasEdge
boolean hasEdge(java.lang.Object first, java.lang.Object second)
- Returns true if this directed graph contains an edge that leaves
from the vertex first and enters the vertex second.
edgeWeight
int edgeWeight(java.lang.Object first, java.lang.Object second)
- Returns the weight of the edge that leaves from the vertex first
and enters the vertex second.
inDegree
int inDegree(java.lang.Object object) throws RepException
- Returns the number of edges that enter the specified vertex.
- Throws:
RepException
outDegree
int outDegree(java.lang.Object vertex) throws RepException
- Returns the number of edges that leave from the specified vertex.
- Throws:
RepException
adjacentsOf
java.lang.Object[] adjacentsOf(java.lang.Object ob) throws RepException
- Returns an array containing all vertices that are adjacent to the
specified vertex. A vertex v is adjacent to a vertex u if there is an
edge that leaves from u and enters v.
The returned array will be "safe" in that no references to it are maintained by this directed graph. In other words, this method must allocate a new array even if this collection is backed by an array. The caller is thus free to modify the returned array.
- Throws:
RepException
isIsolated
boolean isIsolated(java.lang.Object ob) throws RepException
Returns true if the specified vertex is isolated. A vertex is isolated if there are no edges leaving from or entering the vertex, or the only edge leaving from the vertex enters the vertex itself and the only edge entering the vertex leaves from the vertex itself.
- Throws:
RepException
hasEdges
boolean hasEdges()
- Returns true if there are edges in this directed graph.
- Returns:
- true if there are edges in this directed graph.
edgeCount
int edgeCount()
- Returns the number of edges in this directed graph. If this directed
graph contains more than Integer.MAX_VALUE edges, returns
Integer.MAX_VALUE.
edgeWeight
int edgeWeight()
- Returns the sum of the weights of all edges in this directed graph. If
the sum is more than Integer.MAX_VALUE, returns
Integer.MAX_VALUE.
topologicalSort
java.lang.Object[] topologicalSort()
- Returns an array of all of the vertices in this directed graph in some
topological sort order.
The returned array will be "safe" in that no references to it are maintained by this directed graph. In other words, this method must allocate a new array even if this collection is backed by an array. The caller is thus free to modify the returned array.
- Returns:
- an array of all of the vertices in this directed graph in some topological sort order. Returns null if no topological sort is possible.
hasCycle
boolean hasCycle()
- Returns true if there is a cycle in the directed graph.
- Returns:
- true if there is a cycle in the directed graph.
isLinearList
boolean isLinearList()
- Returns true if the directed graph forms a linear list. A
directed graph with no vertices or one vertex without a self loop is
also considered to form a linear list.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

