public class SparseTypedEdgeSet<T> extends AbstractSet<TypedEdge<T>> implements EdgeSet<TypedEdge<T>>, Serializable
EdgeSet
implementation that stores TypedEdge
instances for
a vertex. This class provides additional methods beyond the EdgeSet
interface for interacting with edges on the basis of their type.Constructor and Description |
---|
SparseTypedEdgeSet(int rootVertex)
Creates a new
SparseTypedEdgeSet for the specfied vertex. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(TypedEdge<T> e)
Adds the edge to this set if one of the vertices is the root vertex and
if the non-root vertex has a greater index that this vertex.
|
void |
clear() |
IntSet |
connected()
Returns the set of vertices connected to the root edges.
|
boolean |
connects(int vertex)
Returns true if the root vertex is connected to the provided vertex.
|
boolean |
connects(int vertex,
T type) |
boolean |
contains(Object o) |
SparseTypedEdgeSet<T> |
copy(IntSet vertices)
Copies the edges in this set that are connected to any of the vertices in
the provided set.
|
int |
disconnect(int v)
Removes all edges instances that connect to the specified vertex,
returning the number of edges that were removed, if any.
|
Set<TypedEdge<T>> |
getEdges(int vertex)
Returns the set of
Edge instances that connect the root vertex
with this vertex or an empty set if no such edges exist. |
Set<TypedEdge<T>> |
getEdges(int vertex,
Set<T> types) |
Set<TypedEdge<T>> |
getEdges(T type) |
int |
getRoot()
Returns the vertex to which all edges in this set are connected.
|
boolean |
isEmpty() |
Iterator<TypedEdge<T>> |
iterator() |
boolean |
remove(Object o) |
int |
size() |
Set<T> |
types()
Returns the set of types contained within this set
|
Iterator<TypedEdge<T>> |
uniqueIterator() |
equals, hashCode, removeAll
addAll, containsAll, retainAll, toArray, toArray, toString
public SparseTypedEdgeSet(int rootVertex)
SparseTypedEdgeSet
for the specfied vertex.public boolean add(TypedEdge<T> e)
add
in interface EdgeSet<TypedEdge<T>>
add
in interface Collection<TypedEdge<T>>
add
in interface Set<TypedEdge<T>>
add
in class AbstractCollection<TypedEdge<T>>
true
if the edge was added, false
if the edge was
already present, or if it could not be added to this edge set due
to the root vertex not being connected to the edgepublic void clear()
public IntSet connected()
public boolean connects(int vertex)
public boolean connects(int vertex, T type)
public boolean contains(Object o)
public SparseTypedEdgeSet<T> copy(IntSet vertices)
public int disconnect(int v)
disconnect
in interface EdgeSet<TypedEdge<T>>
public Set<TypedEdge<T>> getEdges(int vertex)
Edge
instances that connect the root vertex
with this vertex or an empty set if no such edges exist.public int getRoot()
public boolean isEmpty()
public boolean remove(Object o)
public int size()
Copyright © 2012. All Rights Reserved.