Package edu.uci.ics.jung.graph
Interface Graph<V,E>
- All Superinterfaces:
Hypergraph<V,E>
- All Known Subinterfaces:
DirectedGraph<V,,E> Forest<V,,E> KPartiteGraph<V,,E> Tree<V,,E> UndirectedGraph<V,E>
- All Known Implementing Classes:
AbstractGraph,AbstractTypedGraph,AggregateGraph,DelegateForest,DelegateTree,DirectedOrderedSparseMultigraph,DirectedSparseGraph,DirectedSparseMultigraph,FastRenderingGraph,GraphDecorator,ObservableGraph,OrderedKAryTree,OrderedSparseMultigraph,SortedSparseMultigraph,SparseGraph,SparseMultigraph,UndirectedOrderedSparseMultigraph,UndirectedSparseGraph,UndirectedSparseMultigraph
A graph consisting of a set of vertices of type
V
set and a set of edges of type E. Edges of this
graph type have exactly two endpoints; whether these endpoints
must be distinct depends on the implementation.
This interface permits, but does not enforce, any of the following common variations of graphs:
- directed and undirected edges
- vertices and edges with attributes (for example, weighted edges)
- vertices and edges of different types (for example, bipartite or multimodal graphs)
- parallel edges (multiple edges which connect a single set of vertices)
- representations as matrices or as adjacency lists or adjacency maps
Definitions (with respect to a given vertex v):
- incoming edge of
v: an edge that can be traversed from a neighbor ofvto reachv - outgoing edge of
v: an edge that can be traversed fromvto reach some neighbor ofv - predecessor of
v: a vertex at the other end of an incoming edge ofv - successor of
v: a vertex at the other end of an outgoing edge ofv
- Author:
- Joshua O'Madadhain
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds edgeeto this graph such that it connects vertexv1tov2.booleanAdds edgeeto this graph such that it connects vertexv1tov2.Ifdirected_edgeis a directed edge in this graph, returns the destination; otherwise returnsnull.getEndpoints(E edge) Returns the endpoints ofedgeas aPair.getInEdges(V vertex) Returns aCollectionview of the incoming edges incident tovertexin this graph.getOpposite(V vertex, E edge) Returns the vertex at the other end ofedgefromvertex.getOutEdges(V vertex) Returns aCollectionview of the outgoing edges incident tovertexin this graph.intgetPredecessorCount(V vertex) Returns the number of predecessors thatvertexhas in this graph.getPredecessors(V vertex) Returns aCollectionview of the predecessors ofvertexin this graph.Ifdirected_edgeis a directed edge in this graph, returns the source; otherwise returnsnull.intgetSuccessorCount(V vertex) Returns the number of successors thatvertexhas in this graph.getSuccessors(V vertex) Returns aCollectionview of the successors ofvertexin this graph.intReturns the number of incoming edges incident tovertex.booleanReturnstrueifvertexis the destination ofedge.booleanisPredecessor(V v1, V v2) Returnstrueifv1is a predecessor ofv2in this graph.booleanReturnstrueifvertexis the source ofedge.booleanisSuccessor(V v1, V v2) Returnstrueifv1is a successor ofv2in this graph.intReturns the number of outgoing edges incident tovertex.Methods inherited from interface edu.uci.ics.jung.graph.Hypergraph
addEdge, addEdge, addVertex, containsEdge, containsVertex, degree, findEdge, findEdgeSet, getDefaultEdgeType, getEdgeCount, getEdgeCount, getEdges, getEdges, getEdgeType, getIncidentCount, getIncidentEdges, getIncidentVertices, getNeighborCount, getNeighbors, getVertexCount, getVertices, isIncident, isNeighbor, removeEdge, removeVertex
-
Method Details
-
getInEdges
Returns aCollectionview of the incoming edges incident tovertexin this graph.- Specified by:
getInEdgesin interfaceHypergraph<V,E> - Parameters:
vertex- the vertex whose incoming edges are to be returned- Returns:
- a
Collectionview of the incoming edges incident tovertexin this graph
-
getOutEdges
Returns aCollectionview of the outgoing edges incident tovertexin this graph.- Specified by:
getOutEdgesin interfaceHypergraph<V,E> - Parameters:
vertex- the vertex whose outgoing edges are to be returned- Returns:
- a
Collectionview of the outgoing edges incident tovertexin this graph
-
getPredecessors
Returns aCollectionview of the predecessors ofvertexin this graph. A predecessor ofvertexis defined as a vertexvwhich is connected tovertexby an edgee, whereeis an outgoing edge ofvand an incoming edge ofvertex.- Specified by:
getPredecessorsin interfaceHypergraph<V,E> - Parameters:
vertex- the vertex whose predecessors are to be returned- Returns:
- a
Collectionview of the predecessors ofvertexin this graph
-
getSuccessors
Returns aCollectionview of the successors ofvertexin this graph. A successor ofvertexis defined as a vertexvwhich is connected tovertexby an edgee, whereeis an incoming edge ofvand an outgoing edge ofvertex.- Specified by:
getSuccessorsin interfaceHypergraph<V,E> - Parameters:
vertex- the vertex whose predecessors are to be returned- Returns:
- a
Collectionview of the successors ofvertexin this graph
-
inDegree
Returns the number of incoming edges incident tovertex. Equivalent togetInEdges(vertex).size().- Specified by:
inDegreein interfaceHypergraph<V,E> - Parameters:
vertex- the vertex whose indegree is to be calculated- Returns:
- the number of incoming edges incident to
vertex
-
outDegree
Returns the number of outgoing edges incident tovertex. Equivalent togetOutEdges(vertex).size().- Specified by:
outDegreein interfaceHypergraph<V,E> - Parameters:
vertex- the vertex whose outdegree is to be calculated- Returns:
- the number of outgoing edges incident to
vertex
-
isPredecessor
Returnstrueifv1is a predecessor ofv2in this graph. Equivalent tov1.getPredecessors().contains(v2).- Parameters:
v1- the first vertex to be queriedv2- the second vertex to be queried- Returns:
trueifv1is a predecessor ofv2, and false otherwise.
-
isSuccessor
Returnstrueifv1is a successor ofv2in this graph. Equivalent tov1.getSuccessors().contains(v2).- Parameters:
v1- the first vertex to be queriedv2- the second vertex to be queried- Returns:
trueifv1is a successor ofv2, and false otherwise.
-
getPredecessorCount
Returns the number of predecessors thatvertexhas in this graph. Equivalent tovertex.getPredecessors().size().- Parameters:
vertex- the vertex whose predecessor count is to be returned- Returns:
- the number of predecessors that
vertexhas in this graph
-
getSuccessorCount
Returns the number of successors thatvertexhas in this graph. Equivalent tovertex.getSuccessors().size().- Parameters:
vertex- the vertex whose successor count is to be returned- Returns:
- the number of successors that
vertexhas in this graph
-
getSource
Ifdirected_edgeis a directed edge in this graph, returns the source; otherwise returnsnull. The source of a directed edgedis defined to be the vertex for whichdis an outgoing edge.directed_edgeis guaranteed to be a directed edge if itsEdgeTypeisDIRECTED.- Specified by:
getSourcein interfaceHypergraph<V,E> - Parameters:
directed_edge- the edge whose source is to be returned- Returns:
- the source of
directed_edgeif it is a directed edge in this graph, ornullotherwise
-
getDest
Ifdirected_edgeis a directed edge in this graph, returns the destination; otherwise returnsnull. The destination of a directed edgedis defined to be the vertex incident todfor whichdis an incoming edge.directed_edgeis guaranteed to be a directed edge if itsEdgeTypeisDIRECTED.- Specified by:
getDestin interfaceHypergraph<V,E> - Parameters:
directed_edge- the edge whose destination is to be returned- Returns:
- the destination of
directed_edgeif it is a directed edge in this graph, ornullotherwise
-
isSource
Returnstrueifvertexis the source ofedge. Equivalent togetSource(edge).equals(vertex).- Parameters:
vertex- the vertex to be queriededge- the edge to be queried- Returns:
trueiffvertexis the source ofedge
-
isDest
Returnstrueifvertexis the destination ofedge. Equivalent togetDest(edge).equals(vertex).- Parameters:
vertex- the vertex to be queriededge- the edge to be queried- Returns:
trueiffvertexis the destination ofedge
-
addEdge
Adds edgeeto this graph such that it connects vertexv1tov2. Equivalent toaddEdge(e, new Pair(v1, v2)). If this graph does not containv1,v2, or both, implementations may choose to either silently add the vertices to the graph or throw anIllegalArgumentException. If this graph assigns edge types to its edges, the edge type ofewill be the default for this graph. SeeHypergraph.addEdge()for a listing of possible reasons for failure.- Parameters:
e- the edge to be addedv1- the first vertex to be connectedv2- the second vertex to be connected- Returns:
trueif the add is successful,falseotherwise- See Also:
-
addEdge
Adds edgeeto this graph such that it connects vertexv1tov2. Equivalent toaddEdge(e, new Pair(v1, v2)). If this graph does not containv1,v2, or both, implementations may choose to either silently add the vertices to the graph or throw anIllegalArgumentException. IfedgeTypeis not legal for this graph, this method will throwIllegalArgumentException. SeeHypergraph.addEdge()for a listing of possible reasons for failure.- Parameters:
e- the edge to be addedv1- the first vertex to be connectedv2- the second vertex to be connectededgeType- the type to be assigned to the edge- Returns:
trueif the add is successful,falseotherwise- See Also:
-
getEndpoints
Returns the endpoints ofedgeas aPair.- Parameters:
edge- the edge whose endpoints are to be returned- Returns:
- the endpoints (incident vertices) of
edge
-
getOpposite
Returns the vertex at the other end ofedgefromvertex. (That is, returns the vertex incident toedgewhich is notvertex.)- Parameters:
vertex- the vertex to be queriededge- the edge to be queried- Returns:
- the vertex at the other end of
edgefromvertex
-