Class GraphPack.Graph
All Packages    This Package    Previous    Next

Class GraphPack.Graph

java.lang.Object
   |
   +----GraphPack.Graph

public class Graph
extends Object
implements GraphInterface
Graph implements a graph data structure with the additional feature of highlighted vertices and edges.

The graph contains a list of all vertices, which is accessed through getV(). Similarly, getE() returns the list of all edges. To examine all vertices in the graph, use a loop: for(Vertex v=\.getV(); v!=null; v=v.nextVertex()) Similarly for the edges use: for(EdgeList e=\.getE(); e!=null; e=e.nextEdge())

The graph also contains a subset of vertices which are highlighted. To access all highlighted vertices use: for(Vertex v=\.getHV(); v!=null; v=v.nextHVertex()) or edges: for(EdgeList e=\.getHE(); e!=null; e=e.nextHEdge())


Graph(UndoMan)

HEEmpty()
return true if no highlighted edges
HEManyElt()
return true if there are >= 2 highlighted edges
HESingleElt()
return true if there is exactly one elt in Highlighted elist
HEbetweenHV()
highlight all edges between highlighted vertices
HVEmpty()
return true if no highlighted vertices
HVManyElt()
return true if there are >= 2 highlighted vertices
HVSingleElt()
return true if there is exactly one elt in Highlighted vlist
Hall()
make all edges and vertices highlighted
addToHE(Edge)
add e to set of highlighted edges
precond: e is not highlighted
addToHV(Vertex)
add v to set of highlighted vertices
precond: v is not highlighted
adde(Edge)
add Edge e to graph
adde(Vertex, Vertex)
create and add edge between v1 and v2.
addv(Vertex)
insert vertex v into graph.
precond: v is not already in graph
addv(double, double)
create and insert vertex with x, y coordinates into graph and return new vertex
addv(double, double, int)
create and insert vertex with x, y coordinates and a given temporary number into graph and return new vertex
clearAll()
clear (delete) all vertices and edges
clearHE()
make set of highlighted edges empty
clearHV()
make set of highlighted vertices empty
connectToHV(Vertex)
create & add edge from v to every highlighted vertex
convert()
return a directed graph which is equivalent to this graph: there will be an edge in each direction.
copy()
return a copy of this graph
copyHV()
return a graph containing copies of all highlighted vertices and edges between them
cutHV()
remove all highlighted vertices and edges between them, and return a graph containing this removed portion of the graph
delFromHE(Edge)
remove e from set of highlighted edges
precond: e is highlighted
delFromHV(Vertex)
remove v from set of highlighted vertices
precond: v is highlighted
delHE()
delete all highlighted edges
delHV()
delete all highlighted vertices
dele(Edge)
delete edge e from graph
delv(Vertex)
delete vertex v from graph
eIn(Vertex, Vertex)
return true if there is an edge between v1 and v2, else false
enumerateV()
assign all vertices temporary consecutive numbers - return highest num
findEdge(Edge)
return edge which is "equal" to e, where "equal" is defined by class Edge\'s method equals
findEdge(Vertex, Vertex)
return the edge between v1 and v2, return null if no edge between v1,v2
findVertex(Vertex)
return a vertex which is "equal" to v, where "equal" is defined by Vertex\'s method equals
getAttachedEdges(Vertex)
return list of edges which are attached to vertex v
getE()
return list of all edges
getHE()
return list of highlighted edges NOTE: user will have to use nextHEdge to traverse list
getHV()
return list of highlighted vertices NOTE: user will have to use nextHVertex to traverse list
getV()
return list of all vertices
isDir()
return true only if this is a directed graph
moveAllHV(double, double)
translate all highlighted vertices by (xtrans, ytrans)
onAddE(Edge)
onAddToHE(Edge)
onAddToHV(Vertex)
onAddV(Vertex)
onDelE(Edge)
onDelFromHE(Edge)
onDelFromHV(Vertex)
onDelV(Vertex)
onTransV(Vertex, double, double)
pasteGraph(GraphInterface, double, double)
insert a copy of graph g into this graph, with one of the new nodes at (x,y).
setUndoMan(UndoMan)
toString()
return string representation of graph
toStringH()
transv(Vertex, double, double)
translate vertex v by (xtrans, ytrans)
vIn(Vertex)
return true if v is in graph, else false

Graph
  public Graph(UndoMan _um)

setUndoMan
  public void setUndoMan(UndoMan _um)
isDir
  public boolean isDir()
return true only if this is a directed graph

onAddV

  protected void onAddV(Vertex v)
onDelV
  protected void onDelV(Vertex v)
onAddE
  protected void onAddE(Edge e)
onDelE
  protected void onDelE(Edge e)
onAddToHV
  protected void onAddToHV(Vertex v)
onDelFromHV
  protected void onDelFromHV(Vertex v)
onAddToHE
  protected void onAddToHE(Edge e)
onDelFromHE
  protected void onDelFromHE(Edge e)
onTransV
  protected void onTransV(Vertex v,
                          double dx,
                          double dy)
convert
  public GraphInterface convert()
return a directed graph which is equivalent to this graph: there will be an edge in each direction.

clearAll

  public void clearAll()
clear (delete) all vertices and edges

addv

  public void addv(Vertex v)
insert vertex v into graph.
precond: v is not already in graph

addv

  public Vertex addv(double x,
                     double y)
create and insert vertex with x, y coordinates into graph and return new vertex

addv

  public Vertex addv(double x,
                     double y,
                     int tempnum)
create and insert vertex with x, y coordinates and a given temporary number into graph and return new vertex

findVertex

  public Vertex findVertex(Vertex v)
return a vertex which is "equal" to v, where "equal" is defined by Vertex\'s method equals

delv

  public void delv(Vertex v)
delete vertex v from graph

vIn

  public boolean vIn(Vertex v)
return true if v is in graph, else false

getV

  public Vertex getV()
return list of all vertices

getAttachedEdges

  public EdgeList getAttachedEdges(Vertex v)
return list of edges which are attached to vertex v

transv

  public void transv(Vertex v,
                     double xtrans,
                     double ytrans)
translate vertex v by (xtrans, ytrans)

enumerateV

  public int enumerateV()
assign all vertices temporary consecutive numbers - return highest num

adde

  public void adde(Edge e)
add Edge e to graph

adde

  public Edge adde(Vertex v1,
                   Vertex v2)
create and add edge between v1 and v2. return new edge

findEdge

  public Edge findEdge(Edge e)
return edge which is "equal" to e, where "equal" is defined by class Edge\'s method equals

findEdge

  public Edge findEdge(Vertex v1,
                       Vertex v2)
return the edge between v1 and v2, return null if no edge between v1,v2

dele

  public void dele(Edge e)
delete edge e from graph

eIn

  public boolean eIn(Vertex v1,
                     Vertex v2)
return true if there is an edge between v1 and v2, else false

getE

  public EdgeList getE()
return list of all edges

toString

  public String toString()
return string representation of graph
Overrides:
toString in class Object

toStringH

  public String toStringH()
HVEmpty
  public boolean HVEmpty()
return true if no highlighted vertices

HEEmpty

  public boolean HEEmpty()
return true if no highlighted edges

HVSingleElt

  public boolean HVSingleElt()
return true if there is exactly one elt in Highlighted vlist

HESingleElt

  public boolean HESingleElt()
return true if there is exactly one elt in Highlighted elist

HVManyElt

  public boolean HVManyElt()
return true if there are >= 2 highlighted vertices

HEManyElt

  public boolean HEManyElt()
return true if there are >= 2 highlighted edges

Hall

  public void Hall()
make all edges and vertices highlighted

getHV

  public Vertex getHV()
return list of highlighted vertices NOTE: user will have to use nextHVertex to traverse list

getHE

  public EdgeList getHE()
return list of highlighted edges NOTE: user will have to use nextHEdge to traverse list

addToHV

  public void addToHV(Vertex v)
add v to set of highlighted vertices
precond: v is not highlighted

addToHE

  public void addToHE(Edge e)
add e to set of highlighted edges
precond: e is not highlighted

delFromHV

  public void delFromHV(Vertex v)
remove v from set of highlighted vertices
precond: v is highlighted

delFromHE

  public void delFromHE(Edge e)
remove e from set of highlighted edges
precond: e is highlighted

delHV

  public void delHV()
delete all highlighted vertices

delHE

  public void delHE()
delete all highlighted edges

clearHV

  public void clearHV()
make set of highlighted vertices empty

clearHE

  public void clearHE()
make set of highlighted edges empty

HEbetweenHV

  public void HEbetweenHV()
highlight all edges between highlighted vertices

connectToHV

  public void connectToHV(Vertex v)
create & add edge from v to every highlighted vertex

moveAllHV

  public void moveAllHV(double xtrans,
                        double ytrans)
translate all highlighted vertices by (xtrans, ytrans)

copy

  public GraphInterface copy()
return a copy of this graph

copyHV

  public GraphInterface copyHV()
return a graph containing copies of all highlighted vertices and edges between them

cutHV

  public GraphInterface cutHV()
remove all highlighted vertices and edges between them, and return a graph containing this removed portion of the graph

pasteGraph

  public void pasteGraph(GraphInterface g,
                         double x,
                         double y)
insert a copy of graph g into this graph, with one of the new nodes at (x,y).

note: to make it easy to move pasted graph - highlighted set becomes the newly pasted nodes


All Packages    This Package    Previous    Next