Class Graph

Class Graph

java.lang.Object
   |
   +----ScreenObject
           |
           +----Vertex
                   |
                   +----Graph

class Graph
extends Vertex

Variable Index

 o nodeVector
data structure is just a bunch of nodes ()

Method Index

 o AddEdge(Vertex, Vertex)
Creates an edge in the graph between two specified vertices
 o AddVertex(int, int, int)
Creates a vertex in the graph with the specified initial values
 o AddVertex(Vertex)
Adds a vertex to the graph
 o ComputeCostAll()
Tallies the total cost of the edges of the graph NOTE: Double counts!!!!
 o ComputeCostNode(Vertex)
Tallies the total local cost of the walkways around a particular node
 o DeleteEdge(Vertex, Vertex)
Deletes an edge between vertices- !!!! needs work !!!!!
 o DeleteNode(int)
Deletes a vertex
 o DeleteNode(Vertex)
Deletes a vertex
 o DeleteSelected()
Deletes every selected vertex and edge
 o DoDraws(Graphics)
Draw's the graph
 o GetVertex(Vertex)
Creates an edge in the graph between two specified vertices
 o isHit(int, int)
Check to see which vertex designated point hits
 o isHit(int, int, int, int)
Check to see which vertex is in designated rectangle ab (or ba) !!!! NOT WORKING !!!
 o MergeNodes(boolean)
Merges nodes in the graph if they overlap
 o MergeNodes(Vertex, Vertex)
Merges two nodes- combines all of v2's edges w/ v1 and then deletes v2 (does not check if nodes overlap)
 o ReSizeNodes(int)
Sets all the nodes to a particular size
 o Select(int, int, int, int)
Selects all vertices and edges within specified bounds (given any pair of points- will switch order)
 o Select(Vertex)
Toggles the Selection of the specified vertex
 o SelectAll()
Selects all the vertices and edges in the graph
 o UnSelectAll()
Deselects all the vertices and edges in the graph

Variables

 o nodeVector
  protected Vector nodeVector
data structure is just a bunch of nodes ()

Methods

 o GetVertex
  public int GetVertex(Vertex v)
Creates an edge in the graph between two specified vertices
Parameters:
v - vertex to find
Returns:
(-1) if not found, otherwise the non-negative location of the vertex
 o AddEdge
  public boolean AddEdge(Vertex v1,
                         Vertex v2)
Creates an edge in the graph between two specified vertices
Parameters:
v1 - vertex 1
v2 - vertex 2
Returns:
boolean- true if new edge created, false if edge exists already
 o AddVertex
  public boolean AddVertex(int x,
                           int y,
                           int s)
Creates a vertex in the graph with the specified initial values
Parameters:
x - x coordinate
y - y coordinate
s - size of vertex
 o AddVertex
  public boolean AddVertex(Vertex v)
Adds a vertex to the graph
Parameters:
v - vertex to be added
 o DeleteEdge
  public boolean DeleteEdge(Vertex v1,
                            Vertex v2)
Deletes an edge between vertices- !!!! needs work !!!!!
Parameters:
v1 - vertex 1
v2 - vertex 2
Returns:
boolean- true if new edge created, false if edge exists already
 o DeleteNode
  public boolean DeleteNode(Vertex v)
Deletes a vertex
Parameters:
v - vertex
Returns:
boolean- true if found and deleted
 o DeleteNode
  public boolean DeleteNode(int i)
Deletes a vertex
Parameters:
i - number of the node to delete
Returns:
boolean- true if found and deleted
 o DeleteSelected
  public int DeleteSelected()
Deletes every selected vertex and edge
Parameters:
i - number of the node to delete
Returns:
int- the number of nodes deleted
 o Select
  public boolean Select(Vertex v)
Toggles the Selection of the specified vertex
Parameters:
v - vertex to select
Returns:
boolean- the new state of the vertex
 o SelectAll
  public boolean SelectAll()
Selects all the vertices and edges in the graph
Returns:
true in all cases
 o UnSelectAll
  public boolean UnSelectAll()
Deselects all the vertices and edges in the graph
Returns:
true in all cases
 o Select
  public void Select(int x0,
                     int y0,
                     int x1,
                     int y1)
Selects all vertices and edges within specified bounds (given any pair of points- will switch order)
Parameters:
x0 - x coordinate of one point
y0 - y coordinate of one point
x1 - x coordinate of other point
y1 - y coordinate of other point
 o MergeNodes
  public boolean MergeNodes(boolean is_select)
Merges nodes in the graph if they overlap
Parameters:
is_select - if true, only merges selected nodes, if false, merges any overlapping node
Returns:
boolean- always true
 o MergeNodes
  public boolean MergeNodes(Vertex v1,
                            Vertex v2)
Merges two nodes- combines all of v2's edges w/ v1 and then deletes v2 (does not check if nodes overlap)
Parameters:
v1 - vertex 1
v2 - vertex 2
Returns:
boolean- always true
 o isHit
  public Vertex isHit(int x,
                      int y)
Check to see which vertex designated point hits
Parameters:
x - x coordinate of point
y - y coordinate of point
Returns:
first vertex hit (null if none)
 o isHit
  public Vector isHit(int x0,
                      int x1,
                      int y0,
                      int y1)
Check to see which vertex is in designated rectangle ab (or ba) !!!! NOT WORKING !!!
Parameters:
x0 - x coordinate of point a
y0 - y coordinate of point a
x1 - x coordinate of point b
y1 - y coordinate of point a
Returns:
Vector of vertices which are in rectangle defined by ab
 o ReSizeNodes
  public void ReSizeNodes(int s)
Sets all the nodes to a particular size
Parameters:
s - size to be set to
 o ComputeCostNode
  public int ComputeCostNode(Vertex v)
Tallies the total local cost of the walkways around a particular node
Parameters:
v - node to compute cost at
Returns:
int length*1 of surrounding walkways
 o ComputeCostAll
  public int ComputeCostAll()
Tallies the total cost of the edges of the graph NOTE: Double counts!!!!
Returns:
int length*1 of edges
 o DoDraws
  public void DoDraws(Graphics g)
Draw's the graph
Parameters:
g - graphics context