An AdjacencyGraph is a graph which is concerned only with the vertices and not with the edges. There are
no explicit edge objects, adjacent vertices are simply accessed as neighbors().
For many use cases this is sufficient.
neighbors() is required to be constant time; iterating over the iterable is required to be linear in the number of neighborsdegreeOf() is required to be at most linear in the number of neighborscontainsEdge() is required to be at most linear in the number of neighborsThe number of vertices may be infinite in which case the user has to take care not to call methods which
will not return (this is similar to an Iterable which may contain an infinite number of elements).
The same applies for the number of neighbors of a vertex.
Think about making Vertex (and, in subclasses, Edge) member classes! cf. Graph example here
no type hierarchy
no supertypes hierarchy
| Attributes | |
empty | Source Codeshared formal Boolean emptyAnswer whether the graph is empty, i.e. contains no vertices. |
notEmpty | Source Codeshared default Boolean notEmptyAnswer whether the graph is not empty, i.e. contains at least one vertex. |
| Inherited Attributes |
Attributes inherited from: Object |
| Methods | |
containsEdge | Source Codeshared default Boolean containsEdge(V source, V target)Answer whether the graph contains an edge from source to target. |
degreeOf | Source Codeshared Integer degreeOf(V vertex)Answer the degree of the given vertex, i.e. the number of neighbors. This method will (obviously) not return if the vertex has inifinite neighbors. |
forEachNeighbor | Source Codeshared void forEachNeighbor(V vertex, void action(V neighbor))Apply action for each neighbor of the given vertex. This method will (obviously) not return if the vertex has an inifinite number of neighbors. |
hasNeighbors | Source Codeshared default Boolean hasNeighbors(V vertex)Answer whether the given vertex has at least one neighbor. |
neighbors | Source Codeshared formal {V*} neighbors(V vertex)All neighbor vertices of the given vertex. A neighbor is the target of an outgoing directed edge or the other endpoint of an undirected edge. |
| Inherited Methods |
Methods inherited from: Object |