public class SparseGraph<V,E> extends AbstractGraph<V,E> implements Graph<V,E>
Graph that is suitable for sparse graphs and
permits both directed and undirected edges.| Modifier and Type | Field and Description |
|---|---|
protected Map<E,Pair<V>> |
directed_edges |
protected static int |
INCIDENT |
protected static int |
INCOMING |
protected static int |
OUTGOING |
protected Map<E,Pair<V>> |
undirected_edges |
protected Map<V,Map<V,E>[]> |
vertex_maps |
| Constructor and Description |
|---|
SparseGraph()
Creates an instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addEdge(E edge,
Pair<? extends V> endpoints,
EdgeType edgeType)
Adds
edge to this graph with the specified endpoints
and EdgeType. |
boolean |
addVertex(V vertex) |
boolean |
containsEdge(E edge) |
boolean |
containsVertex(V vertex) |
E |
findEdge(V v1,
V v2) |
Collection<E> |
findEdgeSet(V v1,
V v2) |
EdgeType |
getDefaultEdgeType() |
V |
getDest(E directed_edge) |
int |
getEdgeCount() |
int |
getEdgeCount(EdgeType edge_type) |
Collection<E> |
getEdges() |
Collection<E> |
getEdges(EdgeType edgeType) |
EdgeType |
getEdgeType(E edge) |
Pair<V> |
getEndpoints(E edge) |
static <V,E> com.google.common.base.Supplier<Graph<V,E>> |
getFactory() |
Collection<E> |
getIncidentEdges(V vertex) |
Collection<E> |
getInEdges(V vertex) |
Collection<V> |
getNeighbors(V vertex) |
Collection<E> |
getOutEdges(V vertex) |
Collection<V> |
getPredecessors(V vertex) |
V |
getSource(E directed_edge) |
Collection<V> |
getSuccessors(V vertex) |
int |
getVertexCount() |
Collection<V> |
getVertices() |
boolean |
isDest(V vertex,
E edge) |
boolean |
isSource(V vertex,
E edge) |
boolean |
removeEdge(E edge) |
boolean |
removeVertex(V vertex) |
addEdge, addEdge, addEdge, addEdge, addEdge, degree, getIncidentCount, getIncidentVertices, getNeighborCount, getOpposite, getPredecessorCount, getSuccessorCount, getValidatedEndpoints, inDegree, isIncident, isNeighbor, isPredecessor, isSuccessor, outDegree, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddEdge, addEdge, getOpposite, getPredecessorCount, getSuccessorCount, inDegree, isPredecessor, isSuccessor, outDegreeaddEdge, addEdge, degree, getIncidentCount, getIncidentVertices, getNeighborCount, isIncident, isNeighborprotected static final int INCOMING
protected static final int OUTGOING
protected static final int INCIDENT
public static <V,E> com.google.common.base.Supplier<Graph<V,E>> getFactory()
V - the vertex type for the graph SupplierE - the edge type for the graph SupplierSupplier that creates an instance of this graph type.public E findEdge(V v1, V v2)
findEdge in interface Hypergraph<V,E>findEdge in class AbstractGraph<V,E>public Collection<E> findEdgeSet(V v1, V v2)
findEdgeSet in interface Hypergraph<V,E>findEdgeSet in class AbstractGraph<V,E>public boolean addEdge(E edge, Pair<? extends V> endpoints, EdgeType edgeType)
AbstractGraphedge to this graph with the specified endpoints
and EdgeType.addEdge in class AbstractGraph<V,E>edge - the edge to be addedendpoints - the endpoints to be connected to this edgeedgeType - the type of edge to addpublic Collection<E> getInEdges(V vertex)
getInEdges in interface Graph<V,E>getInEdges in interface Hypergraph<V,E>public Collection<E> getOutEdges(V vertex)
getOutEdges in interface Graph<V,E>getOutEdges in interface Hypergraph<V,E>public Collection<V> getPredecessors(V vertex)
getPredecessors in interface Graph<V,E>getPredecessors in interface Hypergraph<V,E>public Collection<V> getSuccessors(V vertex)
getSuccessors in interface Graph<V,E>getSuccessors in interface Hypergraph<V,E>public Collection<E> getEdges(EdgeType edgeType)
getEdges in interface Hypergraph<V,E>public EdgeType getEdgeType(E edge)
getEdgeType in interface Hypergraph<V,E>public Collection<E> getEdges()
getEdges in interface Hypergraph<V,E>public Collection<V> getVertices()
getVertices in interface Hypergraph<V,E>public boolean containsVertex(V vertex)
containsVertex in interface Hypergraph<V,E>public boolean containsEdge(E edge)
containsEdge in interface Hypergraph<V,E>public int getEdgeCount()
getEdgeCount in interface Hypergraph<V,E>public int getVertexCount()
getVertexCount in interface Hypergraph<V,E>public Collection<V> getNeighbors(V vertex)
getNeighbors in interface Hypergraph<V,E>public Collection<E> getIncidentEdges(V vertex)
getIncidentEdges in interface Hypergraph<V,E>public boolean addVertex(V vertex)
addVertex in interface Hypergraph<V,E>public boolean removeVertex(V vertex)
removeVertex in interface Hypergraph<V,E>public boolean removeEdge(E edge)
removeEdge in interface Hypergraph<V,E>public int getEdgeCount(EdgeType edge_type)
getEdgeCount in interface Hypergraph<V,E>public EdgeType getDefaultEdgeType()
getDefaultEdgeType in interface Hypergraph<V,E>Copyright © 2016. All rights reserved.