|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.aitools.aq.structure.graph.UndirectedIntHashGraph
public final class UndirectedIntHashGraph
A general implementation for int vertices. Each weight is stored only once in the graph.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface de.aitools.aq.structure.graph.UndirectedIntGraph |
---|
UndirectedIntGraph.Edge |
Field Summary |
---|
Fields inherited from interface de.aitools.aq.structure.graph.UndirectedIntGraph |
---|
DEFAULT_UNCONNECTED_WEIGHT |
Constructor Summary | |
---|---|
UndirectedIntHashGraph()
Create a new graph with default weight for unconnected vertices and default capacity. |
|
UndirectedIntHashGraph(double unconnectedWeight,
int initialCapacity)
Create a new graph. |
|
UndirectedIntHashGraph(int initialCapacity)
Create a new graph with default weight for unconnected vertices. |
Method Summary | |
---|---|
boolean |
addVertex(int vertex)
Adds a vertex to the graph. |
UndirectedIntHashGraph |
clone()
|
boolean |
containsEdge(int vertexA,
int vertexB)
Checks if there exists an edge in the graph connecting the two vertices given as parameters. |
boolean |
containsVertex(int vertex)
Checks if given vertex is contained in the graph. |
UndirectedIntGraph.Edge |
getEdge(int vertexA,
int vertexB)
Returns the Edge connecting the two vertices. |
java.util.Iterator<? extends UndirectedIntGraph.Edge> |
getEdges()
Returns an iterator over all edges of the graph. |
java.util.Iterator<? extends UndirectedIntGraph.Edge> |
getEdgesConnectedTo(int vertex)
Returns an iterator over all edges in the graph to which given vertex is connected to. |
double |
getEdgeWeight(int vertexA,
int vertexB)
Returns the weight of the edge connecting the two vertices. |
double |
getMass(int vertex)
Returns the sum of the weights of all edges connected to given vertex. |
int |
getNumberOfEdges()
Returns the number of edges. |
int |
getNumberOfEdgesConnectedTo(int vertex)
Returns the number of edges connected to given vertex. |
int |
getNumberOfVertices()
Returns the number of vertices. |
double |
getUnconnectedWeight()
Returns the default weight for unconnected vertices. |
int[] |
getVertices()
Returns an array containing all current vertices of this graph. |
int[] |
getVerticesConnectedTo(int vertex)
Returns an array containing all vertices that are connected with given vertex at the moment of this call. |
double |
removeEdge(int vertexA,
int vertexB)
Removes an edge determined by two vertices. |
boolean |
removeVertex(int vertex)
Removes a vertex from the graph. |
double |
setEdgeWeight(int vertexA,
int vertexB,
double weight)
Sets the weight of a edge determined by two vertices. |
void |
setUnconnectedWeight(double unconnectedWeight)
Change the weight that is returned by getEdgeWeight(int, int) if the two vertices are not connected. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UndirectedIntHashGraph()
UndirectedIntGraph
,
UndirectedIntHashGraph
,
setUnconnectedWeight(double)
,
UndirectedIntHashGraph(double, int)
public UndirectedIntHashGraph(int initialCapacity)
initialCapacity
- the initial capacity of vertices (grows
automatically) or a negative value to use a default value.UndirectedIntGraph
,
UndirectedIntHashGraph
,
setUnconnectedWeight(double)
,
UndirectedIntHashGraph(double, int)
public UndirectedIntHashGraph(double unconnectedWeight, int initialCapacity)
unconnectedWeight
- The weight for unconnected vertices.
Default is UndirectedIntGraph.DEFAULT_UNCONNECTED_WEIGHT.initialCapacity
- The initial capacity of vertices (grows
automatically) or a negative value to use a default value.UndirectedIntGraph
,
UndirectedIntHashGraph
,
setUnconnectedWeight(double)
,
UndirectedIntHashGraph(double, int)
,
UndirectedIntGraph.DEFAULT_UNCONNECTED_WEIGHT
Method Detail |
---|
public double getUnconnectedWeight()
UndirectedIntGraph
Returns the default weight for unconnected vertices.
The method getEdgeWeight(int, int) returns a double value for any possible edge connecting two vertices in the graph. If an edge does not exist, the method will return this value.
getUnconnectedWeight
in interface UndirectedIntGraph
UndirectedIntGraph.getEdgeWeight(int, int)
,
UndirectedIntGraph.setUnconnectedWeight(double)
public void setUnconnectedWeight(double unconnectedWeight)
UndirectedIntGraph
setUnconnectedWeight
in interface UndirectedIntGraph
unconnectedWeight
- the new weight for unconnected vertices.UndirectedIntGraph.getEdgeWeight(int, int)
,
UndirectedIntGraph.getUnconnectedWeight()
public int getNumberOfVertices()
UndirectedIntGraph
getNumberOfVertices
in interface UndirectedIntGraph
public int getNumberOfEdges()
UndirectedIntGraph
getNumberOfEdges
in interface UndirectedIntGraph
public int getNumberOfEdgesConnectedTo(int vertex)
UndirectedIntGraph
getNumberOfEdgesConnectedTo
in interface UndirectedIntGraph
vertex
- which vertex to count edges of.
public int[] getVertices()
UndirectedIntGraph
getVertices
in interface UndirectedIntGraph
UndirectedIntGraph.getNumberOfVertices()
public int[] getVerticesConnectedTo(int vertex)
UndirectedIntGraph
getVerticesConnectedTo
in interface UndirectedIntGraph
vertex
- the vertex.
#getNumberOfEdges(int)
public double getMass(int vertex) throws java.util.NoSuchElementException
UndirectedIntGraph
getMass
in interface UndirectedIntGraph
vertex
- the vertex.
java.util.NoSuchElementException
- if the vertex is not part of the
graph.public java.util.Iterator<? extends UndirectedIntGraph.Edge> getEdges()
UndirectedIntGraph
getEdges
in interface UndirectedIntGraph
UndirectedIntGraph.getNumberOfEdges()
public java.util.Iterator<? extends UndirectedIntGraph.Edge> getEdgesConnectedTo(int vertex)
UndirectedIntGraph
getEdgesConnectedTo
in interface UndirectedIntGraph
vertex
- the vertex.
#getNumberOfEdges(int)
public boolean containsVertex(int vertex)
UndirectedIntGraph
containsVertex
in interface UndirectedIntGraph
vertex
- the vertex to look for.
public boolean containsEdge(int vertexA, int vertexB)
UndirectedIntGraph
containsEdge
in interface UndirectedIntGraph
vertexA
- one vertex.vertexB
- the other vertex.
public double getEdgeWeight(int vertexA, int vertexB)
UndirectedIntGraph
getEdgeWeight
in interface UndirectedIntGraph
vertexA
- one vertex.vertexB
- the other vertex.
UndirectedIntGraph.containsEdge(int, int)
,
UndirectedIntGraph.getEdge(int, int)
,
UndirectedIntGraph.getUnconnectedWeight()
public UndirectedIntGraph.Edge getEdge(int vertexA, int vertexB)
UndirectedIntGraph
getEdge
in interface UndirectedIntGraph
vertexA
- one vertex.vertexB
- the other vertex.
UndirectedIntGraph.Edge
,
UndirectedIntGraph.containsEdge(int, int)
,
UndirectedIntGraph.getEdgeWeight(int, int)
,
UndirectedIntGraph.Edge.exists()
public boolean addVertex(int vertex)
UndirectedIntGraph
addVertex
in interface UndirectedIntGraph
vertex
- the vertex to be added.
public boolean removeVertex(int vertex)
UndirectedIntGraph
removeVertex
in interface UndirectedIntGraph
vertex
- the vertex to be removed.
public double setEdgeWeight(int vertexA, int vertexB, double weight)
UndirectedIntGraph
setEdgeWeight
in interface UndirectedIntGraph
vertexA
- one vertex of the edge.vertexB
- the other vertex of the edge.weight
- the new weight of the edge.
UndirectedIntGraph.getUnconnectedWeight()
,
UndirectedIntGraph.getEdgeWeight(int, int)
,
UndirectedIntGraph.removeEdge(int, int)
public double removeEdge(int vertexA, int vertexB)
UndirectedIntGraph
removeEdge
in interface UndirectedIntGraph
vertexA
- one vertex of the edge.vertexB
- the other vertex of the edge.
UndirectedIntGraph.getUnconnectedWeight()
,
UndirectedIntGraph.getEdgeWeight(int, int)
,
UndirectedIntGraph.setEdgeWeight(int, int, double)
public UndirectedIntHashGraph clone()
clone
in interface UndirectedIntGraph
clone
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |