|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectGraph
AdjMatrixGraph
public class AdjMatrixGraph
This is a graph implementation that uses an adjacency matrix to represent edges. The [i,j] element of the adjacency matrix contains a linked list with all the directed edges between nodes i and j.
| Field Summary | |
|---|---|
protected java.util.Vector<java.util.Vector<java.util.LinkedList<Edge>>> |
adjMtrx
The adjacency matrix; |
| Fields inherited from class Graph |
|---|
nNodes |
| Constructor Summary | |
|---|---|
AdjMatrixGraph(int nodes)
It initializes the number of nodes and sets the value of every element of the adjacency matrix to an empty list. |
|
| Method Summary | |
|---|---|
boolean |
addEdge(Edge e)
This is method adds safely an edge to the graph, when the edge is given as an object. |
protected boolean |
addEdgeUnsafely(Edge e)
This is method adds an edge to the graph, when the edge is given as an object. |
java.util.LinkedList<Edge> |
getEdges(int i)
This is method returns the edges starting from a source node. |
java.util.LinkedList<Edge> |
getEdges(int i,
int j)
This is method returns the edges between a source node and a target node. |
void |
removeAllEdges()
This method removes all edges in the graph. |
boolean |
removeEdge(Edge e)
This method removes an edge given as an object. |
Graph |
toAltGraphRepr(Graph g)
If G has the same number of nodes as this graph then the method copies this graph to graph G. |
java.lang.String |
toString()
|
| Methods inherited from class Graph |
|---|
getNNodes |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.util.Vector<java.util.Vector<java.util.LinkedList<Edge>>> adjMtrx
| Constructor Detail |
|---|
public AdjMatrixGraph(int nodes)
nodes - the number of nodes.| Method Detail |
|---|
public boolean addEdge(Edge e)
Graph
addEdge in class Graphe - the edge to be added.
protected boolean addEdgeUnsafely(Edge e)
Graph
addEdgeUnsafely in class Graphe - the edge to be added.
public java.util.LinkedList<Edge> getEdges(int i,
int j)
Graph
getEdges in class Graphi - the source node.j - the target node.
public java.util.LinkedList<Edge> getEdges(int i)
Graph
getEdges in class Graphi - the source node.
public boolean removeEdge(Edge e)
Graph
removeEdge in class Graphe - the edge to remove.
public void removeAllEdges()
Graph
removeAllEdges in class Graphpublic java.lang.String toString()
toString in class java.lang.Objectpublic Graph toAltGraphRepr(Graph g)
Graph
toAltGraphRepr in class Graphg - the graph to copy this graph to.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||