public abstract class Graph extends java.lang.Object implements java.io.Serializable
| Modifier and Type | Field and Description | 
|---|---|
private java.util.ArrayList<Edge> | 
edges  | 
private java.util.ArrayList<Node> | 
nodes  | 
private static long | 
serialVersionUID  | 
| Constructor and Description | 
|---|
Graph()
Constructs a graph with no nodes or edges. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
boolean | 
add(Node n,
   java.awt.geom.Point2D p)
Adds a node to the graph so that the top left corner of
      the bounding rectangle is at the given point. 
 | 
boolean | 
connect(Edge e,
       java.awt.geom.Point2D p1,
       java.awt.geom.Point2D p2)
Adds an edge to the graph that joins the nodes containing
      the given points. 
 | 
void | 
draw(java.awt.Graphics2D g2)
Draws the graph 
 | 
Edge | 
findEdge(java.awt.geom.Point2D p)
Finds an edge containing the given point. 
 | 
Node | 
findNode(java.awt.geom.Point2D p)
Finds a node containing the given point. 
 | 
java.awt.geom.Rectangle2D | 
getBounds(java.awt.Graphics2D g2)
Gets the smallest rectangle enclosing the graph 
 | 
abstract Edge[] | 
getEdgePrototypes()
Gets the edge types of a particular graph type. 
 | 
java.util.List<Edge> | 
getEdges()
Gets the edges of this graph. 
 | 
abstract Node[] | 
getNodePrototypes()
Gets the node types of a particular graph type. 
 | 
java.util.List<Node> | 
getNodes()
Gets the nodes of this graph. 
 | 
void | 
removeEdge(Edge e)
Removes an edge from the graph. 
 | 
void | 
removeNode(Node n)
Removes a node and all edges that start or end with that node 
 | 
private static final long serialVersionUID
public Graph()
public boolean connect(Edge e, java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
e - the edge to addp1 - a point in the starting nodep2 - a point in the ending nodepublic boolean add(Node n, java.awt.geom.Point2D p)
n - the node to addp - the desired locationpublic Node findNode(java.awt.geom.Point2D p)
p - a pointpublic Edge findEdge(java.awt.geom.Point2D p)
p - a pointpublic void draw(java.awt.Graphics2D g2)
g2 - the graphics contextpublic void removeNode(Node n)
n - the node to removepublic void removeEdge(Edge e)
e - the edge to removepublic java.awt.geom.Rectangle2D getBounds(java.awt.Graphics2D g2)
g2 - the graphics contextpublic abstract Node[] getNodePrototypes()
public abstract Edge[] getEdgePrototypes()
public java.util.List<Node> getNodes()