Methods for Graph Interface

Some methods may not be implemented. Follow this link for details. 

 

Graph Interface

void

addEdge (Object fromLabel, Object  toLabel, Object edgeLabel)

Adds an edge with the specified label, between the specified vertices.  Throws an exception if (1) any labels are null or (2) either vertex is missing or (3) fromLabel equals toLabel or (4) the edge is already present.

void

addVertex (Object label)

Adds a vertex with the specified label.  Throws an exception if the label is null or if this graph already contains a vertex with the specified label.

void

clear ()

Removes all vertices and edges from this graph.

void

clearEdgeMarks ()

Clears all edge marks.

void

clearVertexMarks ()

Clears all vertex marks.

Object

clone ()

Returns a shallow copy of this graph.

Collection

collectionView ()

Returns a collection view of the labels of the vertices contained in this graph.

boolean

containsEdge (

Returns true if the graph contains an edge from a vertex with fromLabel to a vertex with toLabel, else returns false.  Throws an exception if either labels is null or either vertex is absent.

boolean

containsVertex (Object label)

Returns true if the graph contains a vertex with the specified label, else return false.  Throws and exception if the label is null.

Iterator

edges ()

Returns an iterator over the edges.

boolean

equals (Object other)

Returns true if the other object is a graph with the same morphology and labels as this graph.

Edge

getEdge (Object fromLabel, Object toLabel)

Returns the edge connecting vertices with the specified labels or null if there is no such edge.  Throws and exception if either labels is null or either vertex is absent.

Vertex

getVertex (Object label)

Returns the vertex with the specified label or null or null if there is no such vertex.  Throws an exception if the label is null.

int

hashCode ()

Returns the hash code value for this graph.

Iterator

incidentEdges (Vertex vertex)

Returns an iterator over edges incident to the specified vertex.  Throws an exception if the specified vertex is null or absent.

boolean

isEmpty ()

Returns true if this graph contains no vertices.

Iterator

iterator ()

Returns an iterator over the labels of the vertices.

Iterator

neighboringVertices (Vertex vertex)

Returns an iterator over the vertices adjacent to the specified vertex.  Throws an exception if the specified vertex is null or absent.

boolean

removeEdge (Object fromLabel, Object toLabel)

If the graph contains an edge between the specified vertices, then removes the edge and returns true, else returns false.  Throws an exception if either label is null or either vertex is absent.

boolean

removeVertex (Object label)

If this graph contains a vertex with the specified label, then removes the vertex and all edges involving this vertex and returns true, else returns false.  Throws an exception if the label is null.

int

size ()

Returns the number of vertices in this graph.

int

sizeEdges ()

Returns the number of edges in this graph.

int

sizeVertices ()

Returns the number of vertices in this graph.

Object[ ]

toArray ()

Returns an array containing all the labels of the vertices in this graph. 

String

toString ()

Returns a string representation of this graph.

Iterator

vertices ()

Returns an iterator over the vertices.

 

 

martin@cc.wwu.edu
Disclaimer

Copyright Martin Osborne 1998-2001
  All rights reserved