|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.7.2) E13403-10 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
java.util.AbstractCollection<T>
javax.ide.util.Graph<T>
public class Graph<T>
A directed graph consisting of vertices of type T. The graph may contain cycles, and is therefore not strictly a DAG. However, this class contains a cycle detection algorithm in the getSortedVertices()
method.
Nested Class Summary | |
---|---|
static class |
Graph.CycleException |
Field Summary | |
---|---|
protected java.util.Map<T,javax.ide.util.Graph.Vertex<T>> |
_vertices |
Constructor Summary | |
---|---|
Graph() |
|
Graph(java.util.Collection<T> vertices) Constructs a graph containing all elements in the specified collection as vertices. |
|
Graph(Graph<T> original) Copy constructor. |
Method Summary | ||
---|---|---|
boolean |
add(T vertex) Adds a vertex to the graph. |
|
void |
connect(T from, T to) Creates a connection between two vertices. |
|
boolean |
contains(java.lang.Object vertex) |
|
java.util.Comparator<T> |
createComparator() Creates a comparator that can be used to compare any two items in the graph based on their sorted order (i.e. |
|
java.util.List<T> |
getInwardEdges(T to) Returns the list of vertices that a connects to a specified vertex. |
|
java.util.List<T> |
getOutwardEdges(T from) Returns the list of vertices that a specified vertex connects to. |
|
java.util.List<T> |
getSortedVertices() Get an ordered list of vertices, sorted such that for any given vertex A with a directed edge to vertex B, index(B) < index(A). |
|
java.util.List<T> |
getSortedVertices(T startVertex) Get an ordered list of vertices, sorted such that for any given vertex A with a directed edge to vertex B, index(B) < index(A). |
|
java.util.List<T> |
getVerticesConnectedTo(T vertex) Get all vertices connected to the specified vertex. |
|
java.util.Iterator<T> |
iterator() Returns an iterator over the vertices in this graph. |
|
boolean |
remove(java.lang.Object vertex) |
|
int |
size() |
|
Graph<T> |
subgraph(java.util.Collection<T> vertices) Returns a new graph containing only the specified vertices. |
|
static
|
unmodifiableGraph(Graph<? extends Z> graph) Returns a graph based on the specified graph, but which does not permit modification. |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, clear, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode |
Field Detail |
---|
protected java.util.Map<T,javax.ide.util.Graph.Vertex<T>> _vertices
Constructor Detail |
---|
public Graph(Graph<T> original)
original
- a graph to copy.public Graph()
public Graph(java.util.Collection<T> vertices)
vertices
- vertices to add to the collection. Note that, per the general contract of #add(T)
, the collection must not contain any duplicate elements. If it does, this constructor will throw an IllegalArgumentException.Method Detail |
---|
public java.util.Comparator<T> createComparator() throws Graph.CycleException
#getSortedVertices(T)
method).
The returned Comparator is not live-connected to the graph. If you make changes to the graph after retrieving a comparator, the comparator will no longer be correct.
Graph.CycleException
public boolean contains(java.lang.Object vertex)
contains
in interface java.util.Collection<T>
contains
in class java.util.AbstractCollection<T>
public boolean add(T vertex)
add
in interface java.util.Collection<T>
add
in class java.util.AbstractCollection<T>
vertex
- a vertex to add to the graph. It's illegal to add a vertex to the graph that is already present. Trying to do so will throw an IllegalArgumentException.public void connect(T from, T to)
from
- a vertex at the "from" end of a directed connection. The vertex must be added first using #add(T)
.to
- a vertex at the "to" end of a directed connection. The vertex must be added first using #add(T)
.java.lang.IllegalArgumentException
- if you attempt to connect a vertex to itself, i.e. if from == to.public java.util.List<T> getOutwardEdges(T from)
from
- a vertex that must be in the graph.public java.util.List<T> getInwardEdges(T to)
to
- a vertex that must be in the graph.public Graph<T> subgraph(java.util.Collection<T> vertices)
vertices
- a collection of vertices to retain.public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
iterator
in interface java.util.Collection<T>
iterator
in class java.util.AbstractCollection<T>
public boolean remove(java.lang.Object vertex)
remove
in interface java.util.Collection<T>
remove
in class java.util.AbstractCollection<T>
vertex
- @inheritDocpublic int size()
size
in interface java.util.Collection<T>
size
in class java.util.AbstractCollection<T>
public java.util.List<T> getSortedVertices() throws Graph.CycleException
Graph.CycleException
public java.util.List<T> getSortedVertices(T startVertex) throws Graph.CycleException
In a dependency graph, this method essentially returns all of the downstream dependencies of the given vertex in an order which satisfies the dependencies.
The first vertex in the returned list will always be startVertex.
startVertex
- the vertex to start from. If you pass null, this method will behave exactly the same as getSortedVertices()
.Graph.CycleException
public java.util.List<T> getVerticesConnectedTo(T vertex) throws Graph.CycleException
vertex
- a vertex. Must not be null.Graph.CycleException
public static <Z> Graph<Z> unmodifiableGraph(Graph<? extends Z> graph)
graph
- the original graph.
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.7.2) E13403-10 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |