public class Graph extends Object
For additional documentation, see Section 4.5 of Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.
| Constructor and Description |
|---|
Graph()
Create an empty graph with no vertices or edges.
|
Graph(In in,
String delimiter)
Create an graph from given input stream using given delimiter.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEdge(String v,
String w)
Add edge v-w to this graph (if it is not already an edge)
|
void |
addVertex(String v)
Add vertex v to this graph (if it is not already a vertex)
|
Iterable<String> |
adjacentTo(String v)
Return the set of neighbors of vertex v as in Iterable.
|
int |
degree(String v)
Degree of this vertex.
|
int |
E()
Number of edges.
|
boolean |
hasEdge(String v,
String w)
Is v-w an edge in this graph?
|
boolean |
hasVertex(String v)
Is v a vertex in this graph?
|
static void |
main(String[] args) |
String |
toString()
Return a string representation of the graph.
|
int |
V()
Number of vertices.
|
Iterable<String> |
vertices()
Return the set of vertices as an Iterable.
|
public int V()
public int E()
public int degree(String v)
public void addEdge(String v, String w)
public void addVertex(String v)
public Iterable<String> adjacentTo(String v)
public boolean hasVertex(String v)
public String toString()
public static void main(String[] args)
Copyright © 2014. All Rights Reserved.