public interface Multigraph<T,E extends TypedEdge<T>> extends Graph<E>
The edge type parameter for a multigraph is used to distinguish between
different edges between the same two nodes. For example, a multigraph may
represents cities with edges indicating the different types of transportation
(e.g. car, train, bus) between two cities. Edge type may additionally have
their own subtypes (e.g., airline carrier, bus company, etc.). This
multigraph class only considers the value of the edge type to determine if
two edges are equal, i.e. two edges between the same nodes are equal if for
their edge types t1 and t2, t1.equals(t2)
.
Modifier and Type | Method and Description |
---|---|
void |
clearEdges(T edgeType)
Removes all the edges in the graph with the specified edge type.
|
boolean |
contains(int vertex1,
int vertex2,
T edgeType)
Returns
true if there exists an edge between vertex1 and
vertex2 of the specified type. |
Multigraph<T,E> |
copy(Set<Integer> vertices)
Creates a copy of this graph containing only the specified number of
vertices and all edges between those vertices.
|
Set<E> |
edges()
Returns the set of typed edges in the graph
|
Set<E> |
edges(T type)
Returns the set of edges with the corresponding type or the empty set if
no edges of that exist.
|
Set<T> |
edgeTypes()
Returns the set of edge types currently present in this graph.
|
Set<E> |
getAdjacencyList(int vertex)
Returns the set of typed edges connected to the vertex.
|
Set<E> |
getEdges(int vertex1,
int vertex2)
Returns the set of
TypedEdge instances that connect the two
vertices. |
Multigraph<T,E> |
subgraph(Set<Integer> vertices)
Returns a view of this graph containing only the specified vertices where
the returned graph's vertinces are renamed (0, ..., n).
|
Multigraph<T,E> |
subgraph(Set<Integer> vertices,
Set<T> edgeTypes)
Returns a subgraph of this graph containing only the specified vertices
and edges of the specified types.
|
void clearEdges(T edgeType)
boolean contains(int vertex1, int vertex2, T edgeType)
true
if there exists an edge between vertex1
and
vertex2
of the specified type.Multigraph<T,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.Set<E> edges(T type)
Set<E> getAdjacencyList(int vertex)
getAdjacencyList
in interface Graph<E extends TypedEdge<T>>
Set<E> getEdges(int vertex1, int vertex2)
TypedEdge
instances that connect the two
vertices. If no edges connect the vertices, the set will be empty but
non-null
.Multigraph<T,E> subgraph(Set<Integer> vertices)
Only edges connecting two vertices in the provided set will be viewable in the subgraph. Any changes to the subgraph will be reflected in this graph and vice versa.
This view allows for direct manipulation of a part of the graph. For example, clearing this subgraph will remove all of its corresponding vertices and edges from the backing graph.
Multigraph<T,E> subgraph(Set<Integer> vertices, Set<T> edgeTypes)
Copyright © 2012. All Rights Reserved.