|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectscg.ac.ni.pmf.newgraph.graphdata.Graph
public final class Graph
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.
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 |
---|
public Graph()
Object.Object()
Method Detail |
---|
public GraphData getData()
public java.util.Enumeration vertices()
Vertex
.public int getOrder()
public Vertex createVertex(double x, double y)
x
- The horizontal coordinate (X).y
- The vertical coordinate (Y).
public Vertex createVertex(int id, double x, double y) throws DuplicateIDException
id
- The ID of the vertex.x
- The X coordinate.y
- The Y coordinate.
DuplicateIDException
- If a vertex with the specified ID already exists.public Vertex getVertex(int id)
null
, if such vertex
does not exist.
id
- The ID of the vertex.
public Vertex getVertex(VertexData vertexData)
vertexData
- The vertex data.
public int getIndex(VertexData vertexData)
vertexData
- The vertex data.
public int getIndex(Vertex vertex)
vertex
- The vertex.
public void moveVertex(int id, float x, float y)
id
- The ID of the vertex.x
- The new X coordinate.y
- The new Y coordinate.public void moveVertexFor(int id, float dx, float dy)
id
- The ID of the vertex.dx
- The X distance.dy
- The Y distance.public void deleteVertex(Vertex v)
v
- The vertex.public void deleteVertex(int id)
id
- The ID.public java.util.Enumeration edges()
Edge
.public int getNumberOfEdges()
public Edge createEdge(int idA, int idB, int multiplicity)
idA
- The ID of one of the endpoints.idB
- The ID of the other endpoint.multiplicity
- The multiplicity of the edge.
public Edge createEdge(int idA, int idB)
idA
- The ID of one of the endpoints.idB
- The ID of the other endpoint.
public Edge createEdge(Vertex va, Vertex vb, int multiplicity)
va
- The first endpoint.vb
- The second endpoint.multiplicity
- The multiplicity of the edge.
public Edge createEdge(Vertex va, Vertex vb)
va
- The first endpoint.vb
- The second endpoint.
public Edge getEdge(int idA, int idB)
null
,
if no such edge exists.
idA
- The ID of one of the endpoints.idB
- The ID of the other endpoint.
public int getIndex(EdgeData edgeData)
edgeData
- The edge data.
public int getIndex(Edge edge)
edge
- The edge.
public Edge getEdge(EdgeData edgeData)
edgeData
- The edge data.
public Edge getEdge(Vertex va, Vertex vb)
null
,
if no such edge exists.
va
- The first vertex.vb
- The second vertex.
public boolean isAdjanced(int idA, int idB)
idA
- The ID of one of the endpoints.idB
- The ID of the other endpoint.
public boolean isAdjanced(Vertex va, Vertex vb)
va
- The first vertex.vb
- The second vertex.
public java.util.Set getIncident(int id)
null
.
id
- The ID of the vertex.
Edge
.public java.util.Set getIncident(Vertex v)
null
.
v
- The vertex.
Edge
.public void deleteEdge(Edge edge)
edge
- The edge.public void deleteEdge(int idA, int idB)
idA
- The ID of one of the endpoints.idB
- The ID of the other endpoints.public void deleteEdge(Vertex va, Vertex vb)
va
- The first endpoint.vb
- The second endpoint.public java.util.Enumeration selectedVertices()
Vertex
.public boolean isSelected(int id)
id
- The vertex.
public boolean isSelected(Vertex v)
v
- The vertex.
public int getSelectedVerticesNo()
public void addToSelection(int id)
id
- The ID of the vertex.public void addToSelection(Vertex v)
v
- The vertex.public void addToSelection(VertexData v)
v
- The vertex data.public void setSelectedVertices(java.util.Collection elements)
elements
- The collection.public void removeFromSelection(int id)
id
- The ID of the vertex.public void removeFromSelection(Vertex v)
v
- The vertex.public void removeFromSelection(VertexData v)
v
- The vertex data.public void clearVertexSelection()
public void connectToSelection(int id)
id
- The ID of the vertex.public void connectToSelection(Vertex v)
v
- The vertex.public void connectToSelection(VertexData v)
v
- The vertex data.public void moveSelection(float dx, float dy)
dx
- The horizontal (X) distance.dy
- The vertical (Y) distance.public void deleteSelectedVertices()
public java.util.Enumeration selectedEdges()
Edge
.public boolean isSelected(int idA, int idB)
idA
- The ID of one of the endpoints.idB
- The ID of the other endpoint.
public boolean isSelected(Edge e)
e
- The edge.
public boolean isSelected(Vertex va, Vertex vb)
va
- One of the edge endpoints.vb
- The other edge endpoint.
public int getSelectedEdgesNo()
public boolean isSelectionEmpty()
public void addToSelection(int idA, int idB)
idA
- The ID of one of the endpoints.idB
- The ID of the other endpoint.public void addToSelection(Edge edge)
edge
- The edge.public void addToSelection(EdgeData edge)
edge
- The edge data.public void addToSelection(Vertex va, Vertex vb)
va
- One of the edge endpoints.vb
- The other edge endpoint.public void setSelectedEdges(java.util.Collection elements)
elements
- The collection.public void removeFromSelection(int idA, int idB)
idA
- The ID of one of the endpoints.idB
- The ID of the other endpoint.public void removeFromSelection(Edge edge)
edge
- The edge.public void removeFromSelection(EdgeData edge)
edge
- The edge data.public void removeFromSelection(Vertex va, Vertex vb)
va
- One of the edge endpoints.vb
- The other edge endpoint.public void clearEdgeSelection()
public void deleteSelectedEdges()
public void clearSelection()
public void selectAll()
public Element getElement(ElementData elementData)
elementData
- The element data.
public void setSelection(java.util.Collection elements)
elements
- A collection of Vertex
and Edge
.public void addToSelection(java.util.Collection elements)
elements
- A collection of Vertex
and Edge
.public void removeFromSelection(java.util.Collection elements)
elements
- A collection of Vertex
and Edge
.public void addToSelection(Element element)
element
- The element.public void addToSelection(ElementData element)
element
- The element data.public void removeFromSelection(Element element)
element
- The element.public void removeFromSelection(ElementData element)
element
- The element data.public boolean isSelected(java.util.Collection elements)
elements
- A collection of Vertex
and Edge
.
public Vertex getPrimarySelectedVertex()
public boolean isPrimarySelected(int id)
id
- The ID of the vertex.
public boolean isPrimarySelected(VertexData vertex)
vertex
- The vertex data.
public boolean isPrimarySelected(Vertex vertex)
vertex
- The vertex.
public void setPrimarySelectedVertex(int id)
id
- The ID of the vertex.public void clearPrimarySelectedVertex()
public void setPrimarySelectedVertex(Vertex v)
v
- The vertex.public Edge getPrimarySelectedEdge()
public boolean isPrimarySelected(int idA, int idB)
idA
- The ID of one of the endpoints.idB
- The ID of the other endpoint.
public boolean isPrimarySelected(EdgeData edge)
edge
- The edge data.public boolean isPrimarySelected(Edge edge)
edge
- The edge.public boolean isPrimarySelected(ElementData element)
element
- The element data.
public boolean isPrimarySelected(Element element)
element
- The element.
public void setPrimarySelectedEdge(int idA, int idB)
idA
- The ID of one of the endpoints.idB
- The ID of the other endpoint.public void setPrimarySelectedEdge(Edge edge)
edge
- The edge.public void clearPrimarySelectedEdge()
public void deleteSelection()
public java.lang.String getFileName()
public java.lang.String getAbsolutePath()
public void clear()
public int degree(int id)
id
- The ID of the vertex.
public java.util.Enumeration neighbors(int id)
id
- The ID of the vertex.
Vertex
.public void relax()
public int[][] adjacencyMatrix()
public int[][] distances()
public java.util.Set getComponent(int id)
id
- The ID of the vertex.
Vertex
.public void create(int[][] m)
m
- The adjacency matrix.
java.lang.IllegalArgumentException
- If the supplied matrix is invalid.public boolean historySnapshot()
public void undo()
public void redo()
public boolean hasUndo()
public boolean hasRedo()
public void addGraphListener(GraphListener gl)
addGraphListener
in interface GraphEventProvider
gl
- The listener which should be notified.public void removeGraphListener(GraphListener gl)
removeGraphListener
in interface GraphEventProvider
gl
- The listener which should no longer be notifiedpublic void refresh()
public boolean isDirty()
public void setDirty(boolean dirty)
dirty
- The dirty flag.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
Object.equals(Object)
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public void addWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexInt weight, int value)
public void addWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexDouble weight, double value)
public void addWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexString weight, java.lang.String value)
public void removeWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.Weight weight)
public int getWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexInt weight)
public double getWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexDouble weight)
public java.lang.String getWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.WeightVertexString weight)
public boolean hasWeight(VertexData v, scg.ac.ni.pmf.newgraph.graphdata.Weight weight)
public java.util.Map getWeights(VertexData v)
public void addWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeInt weight, int value)
public void addWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeDouble weight, double value)
public void addWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeString weight, java.lang.String value)
public void removeWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.Weight weight)
public int getWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeInt weight)
public double getWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeDouble weight)
public java.lang.String getWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.WeightEdgeString weight)
public boolean hasWeight(EdgeData e, scg.ac.ni.pmf.newgraph.graphdata.Weight weight)
public java.util.Map getWeights(EdgeData e)
public void removeWeight(scg.ac.ni.pmf.newgraph.graphdata.Weight weight)
public java.util.Set getAllWeights()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |