|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.rollerjm.graph.AdjacencyMatrixGraph
Title: graphs
Description: Interface which specifies a weighted oriented graph. All search algorithms and client classes use that Interface to deal with graphs. If the implementation changes, no change will be needed in the clients classes (that's the advantages of using Interfaces !).
Copyright: Copyright (c) 2002
Company:
Field Summary | |
private int[][] |
adjacencyMatrix
Adjacency Matrix AM, with AM[start][destination] = weight. |
private int[][] |
adjacencyMatrixInversed
Adjacency Matrix inversed (mathematical meaning) |
private int |
indexCurrentVertex
Current number of vertices contained in the graph |
private java.lang.Object[] |
objectsArray
Array used to map the index used in the Adjacency Matrix and the object contained in a vertex I.e. |
private java.util.HashMap |
verticesMap
Map used to map an object contained in a vertex and the index used in the Adjacency Matrix. |
private int |
verticesNumber
number of vertices in the graph |
Constructor Summary | |
AdjacencyMatrixGraph(int verticesNumber)
|
Method Summary | |
void |
addEdge(java.lang.Object startVertex,
java.lang.Object destinationVertex,
int weight)
add an new edge in the graph. |
void |
addVertex(java.lang.Object vertex)
add a new vertex in the graph |
boolean |
edgeExist(java.lang.Object startVertex,
java.lang.Object destinationVertex)
Remove an edge to the graph |
private java.util.ArrayList |
getAdjacentsFromMatrix(java.lang.Object vertex,
int[][] matrix)
This method is used by getAdjacentVertices and getPredecessors |
java.util.Iterator |
getAdjacentVertices(java.lang.Object vertex)
|
int |
getEdgeWeight(java.lang.Object startVertex,
java.lang.Object destinationVertex)
|
int |
getEdgeWeight(Path path)
|
java.util.Iterator |
getPredecessors(java.lang.Object vertex)
|
private int |
getVertexIndex(java.lang.Object vertex)
|
private java.lang.Object |
getVertexObject(int index)
|
int |
getVerticesNumber()
|
void |
removeEdge(java.lang.Object startVertex,
java.lang.Object destinationVertex)
Remove an edge |
boolean |
vertexExist(java.lang.Object vertex)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private int verticesNumber
private java.util.HashMap verticesMap
private java.lang.Object[] objectsArray
private int indexCurrentVertex
private int[][] adjacencyMatrix
private int[][] adjacencyMatrixInversed
Constructor Detail |
public AdjacencyMatrixGraph(int verticesNumber)
Method Detail |
public int getVerticesNumber()
getVerticesNumber
in interface IGraph
public void addVertex(java.lang.Object vertex)
addVertex
in interface IGraph
vertex
- public void addEdge(java.lang.Object startVertex, java.lang.Object destinationVertex, int weight)
addEdge
in interface IGraph
startVertex
- should be a vertex in the GraphdestinationVertex
- should be a vertex in the Graphweight
- public void removeEdge(java.lang.Object startVertex, java.lang.Object destinationVertex)
removeEdge
in interface IGraph
startVertex
- destinationVertex
- public boolean edgeExist(java.lang.Object startVertex, java.lang.Object destinationVertex)
edgeExist
in interface IGraph
startVertex
- should belong to the GraphdestinationVertex
- should belong to the Graph
public boolean vertexExist(java.lang.Object vertex)
vertexExist
in interface IGraph
vertex
-
public int getEdgeWeight(java.lang.Object startVertex, java.lang.Object destinationVertex)
getEdgeWeight
in interface IGraph
startVertex
- should belong to the GraphdestinationVertex
- should belong to the Graph
public int getEdgeWeight(Path path)
getEdgeWeight
in interface IGraph
path
- list of vertices
public java.util.Iterator getAdjacentVertices(java.lang.Object vertex)
getAdjacentVertices
in interface IGraph
vertex
- should belong to the Graph
public java.util.Iterator getPredecessors(java.lang.Object vertex)
getPredecessors
in interface IGraph
vertex
- should belong to the Graph
private java.util.ArrayList getAdjacentsFromMatrix(java.lang.Object vertex, int[][] matrix)
vertex
- matrix
- Adjacency Matrix inversed or Adjacency Matrix
private int getVertexIndex(java.lang.Object vertex)
vertex
-
private java.lang.Object getVertexObject(int index)
index
- index used in the Adjacency Matrix
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |