public class LabeledGraph<L,E extends Edge> extends GraphAdaptor<E> implements Serializable
Graph
but rather
exposes the backing graph through the #graph()
method, which ensures
that the backing graph is of the appropriate type (or subtype).
The view returned by #graph()
is read-only with respect to
vertices (i.e., edges may be added or removed). This ensures that all vertex
additions or removals to the graph are made through this class.
Constructor and Description |
---|
LabeledGraph(Graph<E> graph) |
LabeledGraph(Graph<E> graph,
Indexer<L> vertexLabels) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(int vertex)
Adds a vertex with the provided index to the graph, returning
true if the vertex was not previously present (optional operation). |
boolean |
add(L vertexLabel) |
boolean |
contains(L vertexLabel) |
LabeledGraph<L,E> |
copy(Set<Integer> vertices)
Creates a copy of this graph containing only the specified number of
vertices and all edges between those vertices.
|
boolean |
remove(L vertexLabel) |
String |
toString() |
add, clear, clearEdges, contains, contains, contains, degree, edges, getAdjacencyList, getEdges, getNeighbors, hasCycles, order, remove, remove, size, subgraph, vertices
public boolean add(L vertexLabel)
public boolean add(int vertex)
true
if the vertex was not previously present (optional operation).add
in interface Graph<E extends Edge>
add
in class GraphAdaptor<E extends Edge>
vertex
- a non-negative index for a vertex. If the graph has size bounds
(i.e. a limited number of vertices), the implementation may throw
an exception if this index exceeds those bounds.IllegalArgumentException
- if adding a vertex that has not
previously been assigned a labelpublic LabeledGraph<L,E> copy(Set<Integer> vertices)
vertices
is
empty a new, empty graph of this instance's type is returned. Any
changes made to this graph will not be reflected in returned copy or
vice-versa.public boolean contains(L vertexLabel)
public boolean remove(L vertexLabel)
public String toString()
GraphAdaptor
toString
in class GraphAdaptor<E extends Edge>
Copyright © 2012. All Rights Reserved.