org.grinvin

Interface Graph

All Superinterfaces:
GraphView
Known Subinterfaces:
MutableGraphModel
Known Implementing Classes:
DefaultGraph, DefaultGraphModel

public interface Graph
extends GraphView

A mutable version of GraphView. Provides methods to add and remove vertices and edges in the graph.

Method Summary

Edge
addNewEdge(Vertex firstEndpoint, Vertex secondEndpoint, Object annotation)
Add a new edge to the graph which joins the given (existing) vertices.
Vertex
addNewVertex(Object annotation)
Create a new vertex and add it to the graph.
void
change(Edge edge, Object annotation)
Change or remove the annotation of the given edge.
void
change(Vertex vertex, Object annotation)
Change or remove the annotation of the given vertex.
void
clear()
Remove all vertices and all edges from this graph.
void
copy(GraphView original)
Make this graph a copy of the given view.
void
remove(Edge e)
Remove the given edge from the graph.
void
remove(Vertex v)
Remove the given vertex from the graph.
void
restore(Edge e)
Restore a edge which was previously removed from the graph.
void
restore(Vertex v)
Restore a vertex which was previously removed from the graph.

Methods inherited from interface org.grinvin.GraphView

areAdjacent, contains, contains, edgeIterator, edges, getEdge, getNumberOfEdges, getNumberOfVertices, getVertex, vertexIterator, vertices

Method Details

addNewEdge

public Edge addNewEdge(Vertex firstEndpoint,
                       Vertex secondEndpoint,
                       Object annotation)
Add a new edge to the graph which joins the given (existing) vertices.
Parameters:
annotation - optional annotation for this edge (or null).
Returns:
the newly created edge.

addNewVertex

public Vertex addNewVertex(Object annotation)
Create a new vertex and add it to the graph. The index of this newly created vertex should be equal to the number of vertices in the graph before that vertex was added.
Parameters:
annotation - optional annotation for this vertex (or null).
Returns:
the newly created vertex.

change

public void change(Edge edge,
                   Object annotation)
Change or remove the annotation of the given edge.
Parameters:
edge - Edge whose annotation should be changed
annotation - new annotation for this element, or null to request removal

change

public void change(Vertex vertex,
                   Object annotation)
Change or remove the annotation of the given vertex.
Parameters:
vertex - Vertex whose annotation should be changed
annotation - new annotation for this element, or null to request removal

clear

public void clear()
Remove all vertices and all edges from this graph.

copy

public void copy(GraphView original)
Make this graph a copy of the given view. Corresponding vertices will have the same index in the copy as in the original. This graph will be cleared prior to the copy operation.

remove

public void remove(Edge e)
Remove the given edge from the graph.

remove

public void remove(Vertex v)
Remove the given vertex from the graph. Also removes all edges incident with this vertex. Removing a vertex makes its index negative and may change the indices of other vertices in the same graph.

restore

public void restore(Edge e)
Restore a edge which was previously removed from the graph.

This method is intended for use by the undo/redo framework and should be called with care. It is supposed to undo a prior removal of that same edge. Clients are urged to instead use addNewEdge(Vertex,Vertex,Object) whenever possible.

Parameters:
e - Edge that should be restored. This must be a edge that was previously removed from the same graph.

restore

public void restore(Vertex v)
Restore a vertex which was previously removed from the graph. The vertex should end up at the same index position as it had before.

This method is intended for use by the undo/redo framework and should be called with care. It is supposed to undo a prior removal of that same vertex. Clients are urged to instead use addNewVertex(Object) whenever possible.

Parameters:
v - Vertex that should be restored. This must be a vertex that was previously removed from the same graph.