public class Graph<V> extends java.lang.Object implements IGraphDataSource<V>, IBiDirectionalGraphDataSource<V>
Constructor and Description |
---|
Graph() |
Modifier and Type | Method and Description |
---|---|
void |
attachObserver(IGraphObserver<V> go)
Attach a new graph observer.
|
void |
deleteEdge(V source,
V target) |
void |
deleteNode(V node) |
java.lang.Integer[] |
deleteRandomEdge() |
void |
detachObserver(IGraphObserver<V> go)
Detach an existing observer.
|
java.util.Set<V> |
getAllNodes()
Get all nodes of the graph.
|
java.util.List<V> |
getSourceNodes(V target)
Returns the source nodes of those edges that end in target.
|
java.util.List<V> |
getTargetNodes(V source)
Get those nodes that are the target of an edge starting with source.
|
void |
insertEdge(V source,
V target) |
void |
insertNode(V node) |
java.lang.Integer[] |
insertRandomEdge() |
java.lang.String |
toString() |
public void insertNode(V node)
public void deleteNode(V node)
public void attachObserver(IGraphObserver<V> go)
IGraphDataSource
attachObserver
in interface IGraphDataSource<V>
go
- the graph observerpublic void detachObserver(IGraphObserver<V> go)
IGraphDataSource
detachObserver
in interface IGraphDataSource<V>
go
- the graph observerpublic java.util.Set<V> getAllNodes()
IGraphDataSource
getAllNodes
in interface IGraphDataSource<V>
public java.util.List<V> getTargetNodes(V source)
IGraphDataSource
getTargetNodes
in interface IGraphDataSource<V>
source
- the source nodepublic java.util.List<V> getSourceNodes(V target)
IBiDirectionalGraphDataSource
List
as
multiple edges can be present between two arbitrary nodes. If no such node can be found than the method should
return null.getSourceNodes
in interface IBiDirectionalGraphDataSource<V>
target
- the target nodepublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Integer[] deleteRandomEdge()
public java.lang.Integer[] insertRandomEdge()