|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGraph
public abstract class Graph
This abstract class defines a set of variables and implements some methods that are common in every implementation of a directed multigraph object. It also specifies the minimum interface that a graph implementation should support. Each graph is described by the number of its nodes and by the set of its weighted edges. The number of nodes and the * is determined when the graph is instantiated, and does not change during the lifetime of the graph. The nodes of the graph are labeled by integers 0,1,..,(n-1), where n is the number of nodes. The set of edges of a graph is not fixed. Initially, a graph contains no edges at all. A graph implementation should support methods for inserting and removing edges. Multi-edges (i.e., from the same source to the same target node) are allowed.
Field Summary | |
---|---|
protected int |
nNodes
The number of nodes of the graph. |
Constructor Summary | |
---|---|
Graph(int nodes)
Class constructor. |
Method Summary | |
---|---|
abstract boolean |
addEdge(Edge e)
This is method adds safely an edge to the graph, when the edge is given as an object. |
protected abstract boolean |
addEdgeUnsafely(Edge e)
This is method adds an edge to the graph, when the edge is given as an object. |
abstract java.util.LinkedList<Edge> |
getEdges(int source)
This is method returns the edges starting from a source node. |
abstract java.util.LinkedList<Edge> |
getEdges(int source,
int target)
This is method returns the edges between a source node and a target node. |
int |
getNNodes()
Returns the number of nodes of the graph. |
abstract void |
removeAllEdges()
This method removes all edges in the graph. |
abstract boolean |
removeEdge(Edge e)
This method removes an edge given as an object. |
abstract Graph |
toAltGraphRepr(Graph G)
If G has the same number of nodes as this graph then the method copies this graph to graph G. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int nNodes
Constructor Detail |
---|
public Graph(int nodes)
Method Detail |
---|
public int getNNodes()
public abstract boolean addEdge(Edge e)
e
- the edge to be added.
protected abstract boolean addEdgeUnsafely(Edge e)
e
- the edge to be added.
public abstract java.util.LinkedList<Edge> getEdges(int source)
source
- the source node.
public abstract java.util.LinkedList<Edge> getEdges(int source, int target)
source
- the source node.target
- the target node.
public abstract boolean removeEdge(Edge e)
e
- the edge to remove.
public abstract void removeAllEdges()
public abstract Graph toAltGraphRepr(Graph G)
G
- the graph to copy this graph to.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |