org.grinvin.graphs

Interface Graph

All Superinterfaces:
GraphView
Known Subinterfaces:
MutableGraphModel, UndoableGraph
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)
Add a new edge to the graph which joins the given (existing) vertices.
Vertex
addNewVertex()
Create a new vertex and add it to the graph.
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.

Methods inherited from interface org.grinvin.graphs.GraphView

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

Method Details

addNewEdge

public Edge addNewEdge(Vertex firstEndpoint,
                       Vertex secondEndpoint)
Add a new edge to the graph which joins the given (existing) vertices.
Returns:
the newly created edge.

addNewVertex

public Vertex addNewVertex()
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.
Returns:
the newly created vertex.

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.