|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.amino.ds.graph.AbstractGraph<E>
org.amino.ds.graph.UndirectedGraph<E>
E
- type of element inside the graph nodepublic class UndirectedGraph<E>
Undirected graph. In this graph, if there is an edge between node A
and node B, we can traverse from A to B and from
B to A. It's the same to say edge A-B or B-A.
This graph doesn't allow duplicated key for all nodes. The constrain comes
from internal structure contains a ConcurrentHashMap
which uses
indexed by key.
The internal expression of graph is based on adjacent list. If we consider
symmetric property of adjacent list expression, we can save half of the
memory. But this trick will down grade time efficiency. We still store the
complete adjacent list.
Constructor Summary | |
---|---|
UndirectedGraph()
|
Method Summary | |
---|---|
boolean |
addEdge(Edge<E> edge)
Add an edge to this graph. |
boolean |
addEdge(E start,
E end,
double weight)
add one edge to graph. |
boolean |
addEdge(Node<E> start,
Node<E> end,
double weight)
add one edge to graph with weight. |
Graph<E> |
clone()
Clone this graph. |
boolean |
removeEdge(Edge<E> edge)
remove all the edges which start from start and end to end. |
boolean |
removeEdge(E start,
E end)
remove all the edges which start from start and end to end. |
boolean |
removeEdge(Node<E> start,
Node<E> end)
remove all the edges which start from start and end to
end . |
boolean |
removeNode(Node<E> node)
remove the node from the graph. |
Methods inherited from class org.amino.ds.graph.AbstractGraph |
---|
add, addAll, addAllNodes, addNode, addNode, clear, contains, containsAll, containsEdge, containsNode, dumpGraph, freeMultiOwnerShip, getAllNodes, getEdges, getEdges, getLinkedEdges, getLinkedNodes, getMultiOwnerShip, getNodes, isEmpty, iterator, remove, removeAll, retainAll, simpleContentionManager, simpleContentionManager, size, toArray, toArray |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode |
Constructor Detail |
---|
public UndirectedGraph()
Method Detail |
---|
public boolean addEdge(E start, E end, double weight)
start
- value in start node. A new node will be added to graph is this
value is not in graph yet.end
- value in end node. A new node will be added to graph is this
value is not in graph yet.weight
- weight of this edge
public boolean addEdge(Node<E> start, Node<E> end, double weight)
start
- start node. A new node will be added to graph is this value is
not in graph yet.end
- end node. A new node will be added to graph is this value is
not in graph yet.weight
- weight of this edge
public boolean addEdge(Edge<E> edge)
edge
- adding edge
public boolean removeEdge(Edge<E> edge)
edge
- edge removed
public boolean removeEdge(Node<E> start, Node<E> end)
start
and end to
end
.
start
- start nodeend
- end node
public boolean removeEdge(E start, E end)
start
- start valueend
- end value
public boolean removeNode(Node<E> node)
removeNode
in interface Graph<E>
removeNode
in class AbstractGraph<E>
node
- node removed
public Graph<E> clone()
clone
in interface Graph<E>
clone
in class AbstractGraph<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |