Class Graph
Class Graph
java.lang.Object
|
+----ScreenObject
|
+----Vertex
|
+----Graph
- class Graph
- extends Vertex
-
nodeVector
- data structure is just a bunch of nodes ()
-
AddEdge(Vertex, Vertex)
- Creates an edge in the graph between two specified vertices
-
AddVertex(int, int, int)
- Creates a vertex in the graph with the specified initial values
-
AddVertex(Vertex)
- Adds a vertex to the graph
-
ComputeCostAll()
- Tallies the total cost of the edges of the graph
NOTE: Double counts!!!!
-
ComputeCostNode(Vertex)
- Tallies the total local cost of the walkways around a particular node
-
DeleteEdge(Vertex, Vertex)
- Deletes an edge between vertices- !!!! needs work !!!!!
-
DeleteNode(int)
- Deletes a vertex
-
DeleteNode(Vertex)
- Deletes a vertex
-
DeleteSelected()
- Deletes every selected vertex and edge
-
DoDraws(Graphics)
- Draw's the graph
-
GetVertex(Vertex)
- Creates an edge in the graph between two specified vertices
-
isHit(int, int)
- Check to see which vertex designated point hits
-
isHit(int, int, int, int)
- Check to see which vertex is in designated rectangle ab (or ba) !!!! NOT WORKING !!!
-
MergeNodes(boolean)
- Merges nodes in the graph if they overlap
-
MergeNodes(Vertex, Vertex)
- Merges two nodes- combines all of v2's edges w/ v1 and then
deletes v2 (does not check if nodes overlap)
-
ReSizeNodes(int)
- Sets all the nodes to a particular size
-
Select(int, int, int, int)
- Selects all vertices and edges within specified bounds
(given any pair of points- will switch order)
-
Select(Vertex)
- Toggles the Selection of the specified vertex
-
SelectAll()
- Selects all the vertices and edges in the graph
-
UnSelectAll()
- Deselects all the vertices and edges in the graph
nodeVector
protected Vector nodeVector
- data structure is just a bunch of nodes ()
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
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
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
AddVertex
public boolean AddVertex(Vertex v)
- Adds a vertex to the graph
- Parameters:
- v - vertex to be added
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
DeleteNode
public boolean DeleteNode(Vertex v)
- Deletes a vertex
- Parameters:
- v - vertex
- Returns:
- boolean- true if found and deleted
DeleteNode
public boolean DeleteNode(int i)
- Deletes a vertex
- Parameters:
- i - number of the node to delete
- Returns:
- boolean- true if found and deleted
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
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
SelectAll
public boolean SelectAll()
- Selects all the vertices and edges in the graph
- Returns:
- true in all cases
UnSelectAll
public boolean UnSelectAll()
- Deselects all the vertices and edges in the graph
- Returns:
- true in all cases
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
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
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
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)
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
ReSizeNodes
public void ReSizeNodes(int s)
- Sets all the nodes to a particular size
- Parameters:
- s - size to be set to
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
ComputeCostAll
public int ComputeCostAll()
- Tallies the total cost of the edges of the graph
NOTE: Double counts!!!!
- Returns:
- int length*1 of edges
DoDraws
public void DoDraws(Graphics g)
- Draw's the graph
- Parameters:
- g - graphics context