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