scg.ac.ni.pmf.newgraph.graphdata
Class Graph

java.lang.Object
  extended by scg.ac.ni.pmf.newgraph.graphdata.Graph
All Implemented Interfaces:
GraphEventProvider

public final class Graph
extends java.lang.Object
implements GraphEventProvider

The class represents a graph which is being edited. It provides access to the methods which modify the graph structure, and the structures used in editing graphs.

Author:
Vladimir Brankov
See Also:
GraphData, Edge, Vertex

Constructor Summary
Graph()
          Constructs an instance of the class.
 
Method Summary
 void addGraphListener(GraphListener gl)
          Adds the listener to the collection of listeners who will be notified when the graph is modified, by sending it one of the messages defined in interface.
 void addToSelection(java.util.Collection elements)
          Adds the specified vertices and edges to the selection.
 void addToSelection(Edge edge)
          Adds the specified edge to selection.
 void addToSelection(EdgeData edge)
          Adds the specified edge to selection.
 void addToSelection(Element element)
          Adds the graph element (vertex or edge) to the selection.
 void addToSelection(ElementData element)
          Adds the graph element (vertex or edge) to the selection.
 void addToSelection(int id)
          Adds the vertex to the selection.
 void addToSelection(int idA, int idB)
          Adds the specified edge to selection.
 void addToSelection(Vertex v)
          Adds the vertex to the selection.
 void addToSelection(VertexData v)
          Adds the vertex to the selection.
 void addToSelection(Vertex va, Vertex vb)
          Adds the specified edge to the selection.
 void addWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeDouble weight, double value)
           
 void addWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeInt weight, int value)
           
 void addWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeString weight, java.lang.String value)
           
 void addWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexDouble weight, double value)
           
 void addWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexInt weight, int value)
           
 void addWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexString weight, java.lang.String value)
           
 int[][] adjacencyMatrix()
          Creates the adjacency matrix of the graph.
 void clear()
          Clears all the data of the graph.
 void clearEdgeSelection()
          Clears the edge selection.
 void clearPrimarySelectedEdge()
          Clears the primary selected edge.
 void clearPrimarySelectedVertex()
          Clears the primary selected vertex.
 void clearSelection()
          Clears the selection.
 void clearVertexSelection()
          Clears the vertex selection.
 void connectToSelection(int id)
          Connects the specified vertex to the selected vertices.
 void connectToSelection(Vertex v)
          Connects the specified vertex to the selected vertices.
 void connectToSelection(VertexData v)
          Connects the specified vertex to the selected vertices.
 void create(int[][] m)
          Creates a graph from the adjacency matrix.
 Edge createEdge(int idA, int idB)
          Creates an edge between the specified endpoints.
 Edge createEdge(int idA, int idB, int multiplicity)
          Creates an edge between the specified endpoints.
 Edge createEdge(Vertex va, Vertex vb)
          Creates an edge between the specified endpoints.
 Edge createEdge(Vertex va, Vertex vb, int multiplicity)
          Creates an edge between the specified endpoints.
 Vertex createVertex(double x, double y)
          Creates a vertex on the given coordinates.
 Vertex createVertex(int id, double x, double y)
          Creates a vertex with the specified ID at the given coordinates.
 int degree(int id)
          Retrieves the degree of the vertex.
 void deleteEdge(Edge edge)
          Deletes the specified edge.
 void deleteEdge(int idA, int idB)
          Deletes the edge between the specified endpoints.
 void deleteEdge(Vertex va, Vertex vb)
          Deletes the edge between the specified endpoints.
 void deleteSelectedEdges()
          Deletes the selected edges.
 void deleteSelectedVertices()
          Deletes the selected vertices.
 void deleteSelection()
          Deletes the selected vertices and edges.
 void deleteVertex(int id)
          Deletes a vertex with the given ID.
 void deleteVertex(Vertex v)
          Deletes the specified vertex.
 int[][] distances()
          Retrieves the array of distances between vertices.
 java.util.Enumeration edges()
          Retrieves the enumeration on all the edges of the graph.
 boolean equals(java.lang.Object o)
          Checks for equality.
 java.lang.String getAbsolutePath()
          Retrieves the file absolute path.
 java.util.Set getAllWeights()
           
 java.util.Set getComponent(int id)
          Retrieves the set of all the vertices that are connected to the given vertex.
 GraphData getData()
          Retrieves the data about the graph.
 Edge getEdge(EdgeData edgeData)
          Retrieves the edge for the given edge data.
 Edge getEdge(int idA, int idB)
          Retrieves the edge with the given vertices as endpoints, or null, if no such edge exists.
 Edge getEdge(Vertex va, Vertex vb)
          Retrieves the edge with the given vertices as endpoints, or null, if no such edge exists.
 Element getElement(ElementData elementData)
          Retrieves the element for the element data.
 java.lang.String getFileName()
          Retrieves the name of the file.
 java.util.Set getIncident(int id)
          Retrieves the set of edges incident with the specified vertex.
 java.util.Set getIncident(Vertex v)
          Retrieves the set of edges incident with the specified vertex.
 int getIndex(Edge edge)
          Retrieves the index of the edge in the edge enumeration.
 int getIndex(EdgeData edgeData)
          Retrieves the index of the edge data in the edge enumeration.
 int getIndex(Vertex vertex)
          Retrieves the index of the data in the adjacency matrix, and in the vertex enumeration.
 int getIndex(VertexData vertexData)
          Retrieves the index of the vertex data in the adjacency matrix, and in the vertex enumeration.
 int getNumberOfEdges()
          Retrieves the number of edges.
 int getOrder()
          Retrieves the order of the graph (the number of vertices).
 Edge getPrimarySelectedEdge()
          Retrieves the primary selected edge.
 Vertex getPrimarySelectedVertex()
          Retrieves the primary selected vertex.
 int getSelectedEdgesNo()
          Retrieves the number of selected edges.
 int getSelectedVerticesNo()
          Retrieves the number of selected vertices.
 Vertex getVertex(int id)
          Retrieves the vertex with the given ID, or null, if such vertex does not exist.
 Vertex getVertex(VertexData vertexData)
          Retrieves the vertex for the given vertex data.
 double getWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeDouble weight)
           
 int getWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeInt weight)
           
 java.lang.String getWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeString weight)
           
 double getWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexDouble weight)
           
 int getWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexInt weight)
           
 java.lang.String getWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexString weight)
           
 java.util.Map getWeights(EdgeData e)
           
 java.util.Map getWeights(VertexData v)
           
 int hashCode()
          Generates the hash code.
 boolean hasRedo()
          Returns true if there are redo steps.
 boolean hasUndo()
          Returns true if there are undo steps.
 boolean hasWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.Weight weight)
           
 boolean hasWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.Weight weight)
           
 boolean historySnapshot()
          Does a history snapshot.
 boolean isAdjanced(int idA, int idB)
          Retrieves are the vertices adjanced.
 boolean isAdjanced(Vertex va, Vertex vb)
          Retrieves are the vertices adjanced.
 boolean isDirty()
          Retrieves was the graph changed after the last save.
 boolean isPrimarySelected(Edge edge)
          Retrieves is the edge primary selected.
 boolean isPrimarySelected(EdgeData edge)
          Retrieves is the edge primary selected.
 boolean isPrimarySelected(Element element)
          Retrieves is the given element primary selected.
 boolean isPrimarySelected(ElementData element)
          Retrieves is the given element primary selected.
 boolean isPrimarySelected(int id)
          Indicates whether the vertex with the given ID is primary selected.
 boolean isPrimarySelected(int idA, int idB)
          Retrieves is the edge with the given endpoints primary selected.
 boolean isPrimarySelected(Vertex vertex)
          Indicates whether the vertex is primary selected.
 boolean isPrimarySelected(VertexData vertex)
          Indicates whether the vertex is primary selected.
 boolean isSelected(java.util.Collection elements)
          Retrieves are all the elements in the collection selected.
 boolean isSelected(Edge e)
          Retrieves is the edge selected.
 boolean isSelected(int id)
          Retrieves is the vertex selected.
 boolean isSelected(int idA, int idB)
          Retrieves is the specified edge selected.
 boolean isSelected(Vertex v)
          Retrieves is the vertex selected.
 boolean isSelected(Vertex va, Vertex vb)
          Retrieves is the edge selected.
 boolean isSelectionEmpty()
          Retrieves is the selection empty.
 void moveSelection(float dx, float dy)
          Moves the selection for the specified distance.
 void moveVertex(int id, float x, float y)
          Moves the specified vertex to the new coordinates.
 void moveVertexFor(int id, float dx, float dy)
          Moves the specified vertex for the specified distance.
 java.util.Enumeration neighbors(int id)
          Retrieves an enumeration of neighbors of the specified vertex.
 void redo()
          Redos the last undod command.
 void refresh()
          The method notifies the graph listener that the graph has changed.
 void relax()
          Does the spring relaxation of the graph.
 void removeFromSelection(java.util.Collection elements)
          Removes the specified vertices and edges from the selection.
 void removeFromSelection(Edge edge)
          Removes the specified edge from the selection.
 void removeFromSelection(EdgeData edge)
          Removes the specified edge from the selection.
 void removeFromSelection(Element element)
          Removes the graph element (vertex or edge) from the selection.
 void removeFromSelection(ElementData element)
          Removes the graph element (vertex or edge) from the selection.
 void removeFromSelection(int id)
          Removes the vertex from the selection.
 void removeFromSelection(int idA, int idB)
          Removes the specified edge from the selection.
 void removeFromSelection(Vertex v)
          Removes the vertex from the selection.
 void removeFromSelection(VertexData v)
          Removes the vertex from the selection.
 void removeFromSelection(Vertex va, Vertex vb)
          Removes the specified edge from the selection.
 void removeGraphListener(GraphListener gl)
          Removes the listener from the collection of listeners.
 void removeWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.Weight weight)
           
 void removeWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.Weight weight)
           
 void removeWeight(scg.ac.ni.pmf.newgraph.graphdata.Weight weight)
           
 void selectAll()
          Selects all vertices and edges.
 java.util.Enumeration selectedEdges()
          Retrieves the enumeration on all the selected edges.
 java.util.Enumeration selectedVertices()
          Retrieves the enumeration on all the selected vertices.
 void setDirty(boolean dirty)
          Sets the dirty flag.
 void setPrimarySelectedEdge(Edge edge)
          Sets the primary selected edge.
 void setPrimarySelectedEdge(int idA, int idB)
          Sets the primary selected edge.
 void setPrimarySelectedVertex(int id)
          Sets the primary selected vertex.
 void setPrimarySelectedVertex(Vertex v)
          Sets the primary selected vertex.
 void setSelectedEdges(java.util.Collection elements)
          Sets the selected edges from the collection of edges.
 void setSelectedVertices(java.util.Collection elements)
          Sets the selected vertices from the collection of vertices.
 void setSelection(java.util.Collection elements)
          Sets the selection.
 java.lang.String toString()
           
 void undo()
          Undos the last command.
 java.util.Enumeration vertices()
          Retrieves the enumeration on all the vertices of the graph.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Graph

public Graph()
Constructs an instance of the class.

See Also:
Object.Object()
Method Detail

getData

public GraphData getData()
Retrieves the data about the graph.

Returns:
GraphData The graph data.

vertices

public java.util.Enumeration vertices()
Retrieves the enumeration on all the vertices of the graph.

Returns:
Enumeration The enumeration of Vertex.

getOrder

public int getOrder()
Retrieves the order of the graph (the number of vertices).

Returns:
int The order.

createVertex

public Vertex createVertex(double x,
                           double y)
Creates a vertex on the given coordinates.

Parameters:
x - The horizontal coordinate (X).
y - The vertical coordinate (Y).
Returns:
vertex The created vertex.

createVertex

public Vertex createVertex(int id,
                           double x,
                           double y)
                    throws DuplicateIDException
Creates a vertex with the specified ID at the given coordinates. If a vertex with the specified ID already exists, this method throws an exception.

Parameters:
id - The ID of the vertex.
x - The X coordinate.
y - The Y coordinate.
Returns:
int The ID of the created vertex.
Throws:
DuplicateIDException - If a vertex with the specified ID already exists.

getVertex

public Vertex getVertex(int id)
Retrieves the vertex with the given ID, or null, if such vertex does not exist.

Parameters:
id - The ID of the vertex.
Returns:
Vertex The vertex.

getVertex

public Vertex getVertex(VertexData vertexData)
Retrieves the vertex for the given vertex data.

Parameters:
vertexData - The vertex data.
Returns:
Vertex The vertex.

getIndex

public int getIndex(VertexData vertexData)
Retrieves the index of the vertex data in the adjacency matrix, and in the vertex enumeration.

Parameters:
vertexData - The vertex data.
Returns:
The index.

getIndex

public int getIndex(Vertex vertex)
Retrieves the index of the data in the adjacency matrix, and in the vertex enumeration.

Parameters:
vertex - The vertex.
Returns:
The index.

moveVertex

public void moveVertex(int id,
                       float x,
                       float y)
Moves the specified vertex to the new coordinates.

Parameters:
id - The ID of the vertex.
x - The new X coordinate.
y - The new Y coordinate.

moveVertexFor

public void moveVertexFor(int id,
                          float dx,
                          float dy)
Moves the specified vertex for the specified distance.

Parameters:
id - The ID of the vertex.
dx - The X distance.
dy - The Y distance.

deleteVertex

public void deleteVertex(Vertex v)
Deletes the specified vertex.

Parameters:
v - The vertex.

deleteVertex

public void deleteVertex(int id)
Deletes a vertex with the given ID.

Parameters:
id - The ID.

edges

public java.util.Enumeration edges()
Retrieves the enumeration on all the edges of the graph.

Returns:
Enumeration The enumeration of Edge.

getNumberOfEdges

public int getNumberOfEdges()
Retrieves the number of edges.

Returns:
int The number of edges.

createEdge

public Edge createEdge(int idA,
                       int idB,
                       int multiplicity)
Creates an edge between the specified endpoints.

Parameters:
idA - The ID of one of the endpoints.
idB - The ID of the other endpoint.
multiplicity - The multiplicity of the edge.
Returns:
The created edge.

createEdge

public Edge createEdge(int idA,
                       int idB)
Creates an edge between the specified endpoints.

Parameters:
idA - The ID of one of the endpoints.
idB - The ID of the other endpoint.
Returns:
The created edge.

createEdge

public Edge createEdge(Vertex va,
                       Vertex vb,
                       int multiplicity)
Creates an edge between the specified endpoints.

Parameters:
va - The first endpoint.
vb - The second endpoint.
multiplicity - The multiplicity of the edge.
Returns:
Edge The created edge.

createEdge

public Edge createEdge(Vertex va,
                       Vertex vb)
Creates an edge between the specified endpoints.

Parameters:
va - The first endpoint.
vb - The second endpoint.
Returns:
Edge The created edge.

getEdge

public Edge getEdge(int idA,
                    int idB)
Retrieves the edge with the given vertices as endpoints, or null, if no such edge exists.

Parameters:
idA - The ID of one of the endpoints.
idB - The ID of the other endpoint.
Returns:
Edge The edge.

getIndex

public int getIndex(EdgeData edgeData)
Retrieves the index of the edge data in the edge enumeration.

Parameters:
edgeData - The edge data.
Returns:
The index.

getIndex

public int getIndex(Edge edge)
Retrieves the index of the edge in the edge enumeration.

Parameters:
edge - The edge.
Returns:
The index.

getEdge

public Edge getEdge(EdgeData edgeData)
Retrieves the edge for the given edge data.

Parameters:
edgeData - The edge data.
Returns:
Edge The edge.

getEdge

public Edge getEdge(Vertex va,
                    Vertex vb)
Retrieves the edge with the given vertices as endpoints, or null, if no such edge exists.

Parameters:
va - The first vertex.
vb - The second vertex.
Returns:
Edge The edge.

isAdjanced

public boolean isAdjanced(int idA,
                          int idB)
Retrieves are the vertices adjanced.

Parameters:
idA - The ID of one of the endpoints.
idB - The ID of the other endpoint.
Returns:
boolean Indicates are the vertices adjanced.

isAdjanced

public boolean isAdjanced(Vertex va,
                          Vertex vb)
Retrieves are the vertices adjanced.

Parameters:
va - The first vertex.
vb - The second vertex.
Returns:
boolean Indicates are the vertices adjanced.

getIncident

public java.util.Set getIncident(int id)
Retrieves the set of edges incident with the specified vertex. If the vertex does not exist, returns null.

Parameters:
id - The ID of the vertex.
Returns:
Set The set of Edge.

getIncident

public java.util.Set getIncident(Vertex v)
Retrieves the set of edges incident with the specified vertex. If the vertex does not exist, returns null.

Parameters:
v - The vertex.
Returns:
Set The set of Edge.

deleteEdge

public void deleteEdge(Edge edge)
Deletes the specified edge.

Parameters:
edge - The edge.

deleteEdge

public void deleteEdge(int idA,
                       int idB)
Deletes the edge between the specified endpoints.

Parameters:
idA - The ID of one of the endpoints.
idB - The ID of the other endpoints.

deleteEdge

public void deleteEdge(Vertex va,
                       Vertex vb)
Deletes the edge between the specified endpoints.

Parameters:
va - The first endpoint.
vb - The second endpoint.

selectedVertices

public java.util.Enumeration selectedVertices()
Retrieves the enumeration on all the selected vertices.

Returns:
Enumeration The enumeration of Vertex.

isSelected

public boolean isSelected(int id)
Retrieves is the vertex selected.

Parameters:
id - The vertex.
Returns:
boolean Indicates is the vertex selected.

isSelected

public boolean isSelected(Vertex v)
Retrieves is the vertex selected.

Parameters:
v - The vertex.
Returns:
boolean Indicates is the vertex selected.

getSelectedVerticesNo

public int getSelectedVerticesNo()
Retrieves the number of selected vertices.

Returns:
int The number of selected vertices.

addToSelection

public void addToSelection(int id)
Adds the vertex to the selection.

Parameters:
id - The ID of the vertex.

addToSelection

public void addToSelection(Vertex v)
Adds the vertex to the selection.

Parameters:
v - The vertex.

addToSelection

public void addToSelection(VertexData v)
Adds the vertex to the selection.

Parameters:
v - The vertex data.

setSelectedVertices

public void setSelectedVertices(java.util.Collection elements)
Sets the selected vertices from the collection of vertices. The collection can contain other graph elements as well, but only the vertices count.

Parameters:
elements - The collection.

removeFromSelection

public void removeFromSelection(int id)
Removes the vertex from the selection.

Parameters:
id - The ID of the vertex.

removeFromSelection

public void removeFromSelection(Vertex v)
Removes the vertex from the selection.

Parameters:
v - The vertex.

removeFromSelection

public void removeFromSelection(VertexData v)
Removes the vertex from the selection.

Parameters:
v - The vertex data.

clearVertexSelection

public void clearVertexSelection()
Clears the vertex selection.


connectToSelection

public void connectToSelection(int id)
Connects the specified vertex to the selected vertices.

Parameters:
id - The ID of the vertex.

connectToSelection

public void connectToSelection(Vertex v)
Connects the specified vertex to the selected vertices.

Parameters:
v - The vertex.

connectToSelection

public void connectToSelection(VertexData v)
Connects the specified vertex to the selected vertices.

Parameters:
v - The vertex data.

moveSelection

public void moveSelection(float dx,
                          float dy)
Moves the selection for the specified distance.

Parameters:
dx - The horizontal (X) distance.
dy - The vertical (Y) distance.

deleteSelectedVertices

public void deleteSelectedVertices()
Deletes the selected vertices.


selectedEdges

public java.util.Enumeration selectedEdges()
Retrieves the enumeration on all the selected edges.

Returns:
Enumeration The enumeration of Edge.

isSelected

public boolean isSelected(int idA,
                          int idB)
Retrieves is the specified edge selected.

Parameters:
idA - The ID of one of the endpoints.
idB - The ID of the other endpoint.
Returns:
boolean Indicates is the edge selected.

isSelected

public boolean isSelected(Edge e)
Retrieves is the edge selected.

Parameters:
e - The edge.
Returns:
boolean Indicates is the edge selected.

isSelected

public boolean isSelected(Vertex va,
                          Vertex vb)
Retrieves is the edge selected.

Parameters:
va - One of the edge endpoints.
vb - The other edge endpoint.
Returns:
boolean Indicates is the edge selected.

getSelectedEdgesNo

public int getSelectedEdgesNo()
Retrieves the number of selected edges.

Returns:
int The number of selected edges.

isSelectionEmpty

public boolean isSelectionEmpty()
Retrieves is the selection empty.

Returns:
boolean If the selection is empty.

addToSelection

public void addToSelection(int idA,
                           int idB)
Adds the specified edge to selection.

Parameters:
idA - The ID of one of the endpoints.
idB - The ID of the other endpoint.

addToSelection

public void addToSelection(Edge edge)
Adds the specified edge to selection.

Parameters:
edge - The edge.

addToSelection

public void addToSelection(EdgeData edge)
Adds the specified edge to selection.

Parameters:
edge - The edge data.

addToSelection

public void addToSelection(Vertex va,
                           Vertex vb)
Adds the specified edge to the selection.

Parameters:
va - One of the edge endpoints.
vb - The other edge endpoint.

setSelectedEdges

public void setSelectedEdges(java.util.Collection elements)
Sets the selected edges from the collection of edges. The collection can contain other graph elements as well, but only edges count.

Parameters:
elements - The collection.

removeFromSelection

public void removeFromSelection(int idA,
                                int idB)
Removes the specified edge from the selection.

Parameters:
idA - The ID of one of the endpoints.
idB - The ID of the other endpoint.

removeFromSelection

public void removeFromSelection(Edge edge)
Removes the specified edge from the selection.

Parameters:
edge - The edge.

removeFromSelection

public void removeFromSelection(EdgeData edge)
Removes the specified edge from the selection.

Parameters:
edge - The edge data.

removeFromSelection

public void removeFromSelection(Vertex va,
                                Vertex vb)
Removes the specified edge from the selection.

Parameters:
va - One of the edge endpoints.
vb - The other edge endpoint.

clearEdgeSelection

public void clearEdgeSelection()
Clears the edge selection.


deleteSelectedEdges

public void deleteSelectedEdges()
Deletes the selected edges.


clearSelection

public void clearSelection()
Clears the selection.


selectAll

public void selectAll()
Selects all vertices and edges.


getElement

public Element getElement(ElementData elementData)
Retrieves the element for the element data.

Parameters:
elementData - The element data.
Returns:
Element The element.

setSelection

public void setSelection(java.util.Collection elements)
Sets the selection.

Parameters:
elements - A collection of Vertex and Edge.

addToSelection

public void addToSelection(java.util.Collection elements)
Adds the specified vertices and edges to the selection.

Parameters:
elements - A collection of Vertex and Edge.

removeFromSelection

public void removeFromSelection(java.util.Collection elements)
Removes the specified vertices and edges from the selection.

Parameters:
elements - A collection of Vertex and Edge.

addToSelection

public void addToSelection(Element element)
Adds the graph element (vertex or edge) to the selection.

Parameters:
element - The element.

addToSelection

public void addToSelection(ElementData element)
Adds the graph element (vertex or edge) to the selection.

Parameters:
element - The element data.

removeFromSelection

public void removeFromSelection(Element element)
Removes the graph element (vertex or edge) from the selection.

Parameters:
element - The element.

removeFromSelection

public void removeFromSelection(ElementData element)
Removes the graph element (vertex or edge) from the selection.

Parameters:
element - The element data.

isSelected

public boolean isSelected(java.util.Collection elements)
Retrieves are all the elements in the collection selected.

Parameters:
elements - A collection of Vertex and Edge.
Returns:
boolean Indicates whether all the elements in the collection are selected.

getPrimarySelectedVertex

public Vertex getPrimarySelectedVertex()
Retrieves the primary selected vertex.

Returns:
Vertex The vertex.

isPrimarySelected

public boolean isPrimarySelected(int id)
Indicates whether the vertex with the given ID is primary selected.

Parameters:
id - The ID of the vertex.
Returns:
boolean Indicates whether the vertex is primary selected.

isPrimarySelected

public boolean isPrimarySelected(VertexData vertex)
Indicates whether the vertex is primary selected.

Parameters:
vertex - The vertex data.
Returns:
boolean Indicates whether the vertex is primary selected.

isPrimarySelected

public boolean isPrimarySelected(Vertex vertex)
Indicates whether the vertex is primary selected.

Parameters:
vertex - The vertex.
Returns:
boolean Indicates whether the vertex is primary selected.

setPrimarySelectedVertex

public void setPrimarySelectedVertex(int id)
Sets the primary selected vertex.

Parameters:
id - The ID of the vertex.

clearPrimarySelectedVertex

public void clearPrimarySelectedVertex()
Clears the primary selected vertex.


setPrimarySelectedVertex

public void setPrimarySelectedVertex(Vertex v)
Sets the primary selected vertex.

Parameters:
v - The vertex.

getPrimarySelectedEdge

public Edge getPrimarySelectedEdge()
Retrieves the primary selected edge.

Returns:
Edge The edge.

isPrimarySelected

public boolean isPrimarySelected(int idA,
                                 int idB)
Retrieves is the edge with the given endpoints primary selected.

Parameters:
idA - The ID of one of the endpoints.
idB - The ID of the other endpoint.
Returns:
boolean Indicates whether the edge is primary selected.

isPrimarySelected

public boolean isPrimarySelected(EdgeData edge)
Retrieves is the edge primary selected.

Parameters:
edge - The edge data.

isPrimarySelected

public boolean isPrimarySelected(Edge edge)
Retrieves is the edge primary selected.

Parameters:
edge - The edge.

isPrimarySelected

public boolean isPrimarySelected(ElementData element)
Retrieves is the given element primary selected.

Parameters:
element - The element data.
Returns:
boolean Indicates whether the element is primary selected.

isPrimarySelected

public boolean isPrimarySelected(Element element)
Retrieves is the given element primary selected.

Parameters:
element - The element.
Returns:
boolean Indicates whether the element is primary selected.

setPrimarySelectedEdge

public void setPrimarySelectedEdge(int idA,
                                   int idB)
Sets the primary selected edge.

Parameters:
idA - The ID of one of the endpoints.
idB - The ID of the other endpoint.

setPrimarySelectedEdge

public void setPrimarySelectedEdge(Edge edge)
Sets the primary selected edge.

Parameters:
edge - The edge.

clearPrimarySelectedEdge

public void clearPrimarySelectedEdge()
Clears the primary selected edge.


deleteSelection

public void deleteSelection()
Deletes the selected vertices and edges.


getFileName

public java.lang.String getFileName()
Retrieves the name of the file.

Returns:
String The name of the file.

getAbsolutePath

public java.lang.String getAbsolutePath()
Retrieves the file absolute path.

Returns:
String The file absolute path.

clear

public void clear()
Clears all the data of the graph.


degree

public int degree(int id)
Retrieves the degree of the vertex.

Parameters:
id - The ID of the vertex.
Returns:
int The degree.

neighbors

public java.util.Enumeration neighbors(int id)
Retrieves an enumeration of neighbors of the specified vertex.

Parameters:
id - The ID of the vertex.
Returns:
Enumeration An enumeration of Vertex.

relax

public void relax()
Does the spring relaxation of the graph.


adjacencyMatrix

public int[][] adjacencyMatrix()
Creates the adjacency matrix of the graph.

Returns:
boolean The adjacency matrix.

distances

public int[][] distances()
Retrieves the array of distances between vertices. Implements the Dijkstra's algorithm.

Returns:
int[][] The array of distances.

getComponent

public java.util.Set getComponent(int id)
Retrieves the set of all the vertices that are connected to the given vertex.

Parameters:
id - The ID of the vertex.
Returns:
Set The set of Vertex.

create

public void create(int[][] m)
Creates a graph from the adjacency matrix.

Parameters:
m - The adjacency matrix.
Throws:
java.lang.IllegalArgumentException - If the supplied matrix is invalid.

historySnapshot

public boolean historySnapshot()
Does a history snapshot. The history snapshot remembers the state of the graph, and uses it for the undo and redo operations. If the graph didn't change, the snapshot is not taken.

Returns:
boolean Indicates whether the history snapshot was taken.

undo

public void undo()
Undos the last command.


redo

public void redo()
Redos the last undod command.


hasUndo

public boolean hasUndo()
Returns true if there are undo steps.

Returns:
boolean True, if there are undo steps.

hasRedo

public boolean hasRedo()
Returns true if there are redo steps.

Returns:
boolean True, if there are redo steps.

addGraphListener

public void addGraphListener(GraphListener gl)
Adds the listener to the collection of listeners who will be notified when the graph is modified, by sending it one of the messages defined in interface.

Specified by:
addGraphListener in interface GraphEventProvider
Parameters:
gl - The listener which should be notified.

removeGraphListener

public void removeGraphListener(GraphListener gl)
Removes the listener from the collection of listeners.

Specified by:
removeGraphListener in interface GraphEventProvider
Parameters:
gl - The listener which should no longer be notified

refresh

public void refresh()
The method notifies the graph listener that the graph has changed.


isDirty

public boolean isDirty()
Retrieves was the graph changed after the last save.

Returns:
boolean

setDirty

public void setDirty(boolean dirty)
Sets the dirty flag.

Parameters:
dirty - The dirty flag.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Checks for equality.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Generates the hash code.

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

addWeight

public void addWeight(VertexData v,
                      scg.ac.ni.pmf.newgraph.graphdata.WeightVertexInt weight,
                      int value)

addWeight

public void addWeight(VertexData v,
                      scg.ac.ni.pmf.newgraph.graphdata.WeightVertexDouble weight,
                      double value)

addWeight

public void addWeight(VertexData v,
                      scg.ac.ni.pmf.newgraph.graphdata.WeightVertexString weight,
                      java.lang.String value)

removeWeight

public void removeWeight(VertexData v,
                         scg.ac.ni.pmf.newgraph.graphdata.Weight weight)

getWeight

public int getWeight(VertexData v,
                     scg.ac.ni.pmf.newgraph.graphdata.WeightVertexInt weight)

getWeight

public double getWeight(VertexData v,
                        scg.ac.ni.pmf.newgraph.graphdata.WeightVertexDouble weight)

getWeight

public java.lang.String getWeight(VertexData v,
                                  scg.ac.ni.pmf.newgraph.graphdata.WeightVertexString weight)

hasWeight

public boolean hasWeight(VertexData v,
                         scg.ac.ni.pmf.newgraph.graphdata.Weight weight)

getWeights

public java.util.Map getWeights(VertexData v)

addWeight

public void addWeight(EdgeData e,
                      scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeInt weight,
                      int value)

addWeight

public void addWeight(EdgeData e,
                      scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeDouble weight,
                      double value)

addWeight

public void addWeight(EdgeData e,
                      scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeString weight,
                      java.lang.String value)

removeWeight

public void removeWeight(EdgeData e,
                         scg.ac.ni.pmf.newgraph.graphdata.Weight weight)

getWeight

public int getWeight(EdgeData e,
                     scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeInt weight)

getWeight

public double getWeight(EdgeData e,
                        scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeDouble weight)

getWeight

public java.lang.String getWeight(EdgeData e,
                                  scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeString weight)

hasWeight

public boolean hasWeight(EdgeData e,
                         scg.ac.ni.pmf.newgraph.graphdata.Weight weight)

getWeights

public java.util.Map getWeights(EdgeData e)

removeWeight

public void removeWeight(scg.ac.ni.pmf.newgraph.graphdata.Weight weight)

getAllWeights

public java.util.Set getAllWeights()


Copyright © 2004 Dragan Stevanovic, Vladimir Brankov.