edu.stanford.math.plex4.graph
public class UndirectedWeightedListGraph extends java.lang.Object implements AbstractWeightedUndirectedGraph
| Constructor and Description |
|---|
UndirectedWeightedListGraph(int numVertices)
Constructor which initializes the graph to consist of disconnected
vertices.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEdge(int i,
int j)
This function adds the edge (i, j) to the graph.
|
void |
addEdge(int i,
int j,
double weight)
This function adds an edge with specified weight.
|
boolean |
containsEdge(int i,
int j)
This function returns true if the edge (i, j) is in the graph,
and false otherwise.
|
int |
getDegree(int v) |
int[] |
getDegreeSequence() |
gnu.trove.TIntHashSet |
getLowerNeighbors(int i)
This function returns the set of neighbors of vertex i in the graph
which have indices less than i.
|
int[] |
getNeighbors(int v) |
int |
getNumEdges()
Gets the number of edges in the graph.
|
int |
getNumVertices()
Gets the number of vertices in the graph.
|
gnu.trove.TIntObjectHashMap<gnu.trove.TIntHashSet> |
getUnweightedAdjacencySets() |
double |
getWeight(int i,
int j)
This function returns the weight of the edge (i, j).
|
java.util.Iterator<edu.stanford.math.primitivelib.autogen.pair.IntIntPair> |
iterator()
This function returns an edge iterator that allows the user to
iterate over the set of edges in the graph.
|
void |
removeEdge(int i,
int j)
This function removes the edge (i, j) from the graph.
|
UndirectedListGraph |
toUnweightedGraph() |
public UndirectedWeightedListGraph(int numVertices)
numVertices - the number of vertices to initialize the graph withpublic void addEdge(int i,
int j,
double weight)
AbstractWeightedUndirectedGraphaddEdge in interface AbstractWeightedUndirectedGraphi - the index of the first vertex of the edgej - the index of the second vertex of the edgeweight - the weight of the edgepublic double getWeight(int i,
int j)
AbstractWeightedUndirectedGraphgetWeight in interface AbstractWeightedUndirectedGraphi - the index of the first vertex of the edgej - the index of the second vertex of the edgepublic void addEdge(int i,
int j)
AbstractUndirectedGraphaddEdge in interface AbstractUndirectedGraphi - the first vertex of the edge to addj - the second vertex of the edge to addpublic boolean containsEdge(int i,
int j)
AbstractUndirectedGraphcontainsEdge in interface AbstractUndirectedGraphi - the first vertex of the edgej - the second vertex of the edgepublic int getNumEdges()
AbstractUndirectedGraphgetNumEdges in interface AbstractUndirectedGraphpublic int getNumVertices()
AbstractUndirectedGraphgetNumVertices in interface AbstractUndirectedGraphpublic void removeEdge(int i,
int j)
AbstractUndirectedGraphremoveEdge in interface AbstractUndirectedGraphi - the first vertex of the edge to addj - the second vertex of the edge to addpublic gnu.trove.TIntHashSet getLowerNeighbors(int i)
getLowerNeighbors in interface AbstractUndirectedGraphi - the vertex to querypublic gnu.trove.TIntObjectHashMap<gnu.trove.TIntHashSet> getUnweightedAdjacencySets()
public UndirectedListGraph toUnweightedGraph()
public java.util.Iterator<edu.stanford.math.primitivelib.autogen.pair.IntIntPair> iterator()
AbstractUndirectedGraphiterator in interface AbstractUndirectedGraphiterator in interface java.lang.Iterable<edu.stanford.math.primitivelib.autogen.pair.IntIntPair>public int getDegree(int v)
getDegree in interface AbstractUndirectedGraphpublic int[] getDegreeSequence()
getDegreeSequence in interface AbstractUndirectedGraphpublic int[] getNeighbors(int v)
getNeighbors in interface AbstractUndirectedGraph