mascoptLib.abstractGraph
Class AbstractGraph

java.lang.Object
  extended bymascoptLib.util.ObservableObject
      extended bymascoptLib.abstractGraph.MascoptObject
          extended bymascoptLib.abstractGraph.AbstractGraph
All Implemented Interfaces:
Cloneable, MascoptObjectInterface, MascoptWritableInterface, Observer
Direct Known Subclasses:
AbstractPath, DiGraph, Graph

public abstract class AbstractGraph
extends MascoptObject

The AbstractGraph class constructs a non directed graph using a vertex set and an edge set. It guaranty that, at any time, the AbstractEdgeSet and AbstractVertexSet objects stay coherent. It provides facilities to copy graphs and construct subgraphs. AbstractGraph derives from MascoptObject.

Author:
Jean-Francois Lalande (Jean-Francois.Lalande@sophia.inria.fr)

Field Summary
 
Fields inherited from class mascoptLib.util.ObservableObject
stopNotifyValueMechanism
 
Constructor Summary
AbstractGraph()
          Default Constructor of the graph.
AbstractGraph(AbstractGraph superGraph)
          Constructor of a subgraph.
AbstractGraph(AbstractGraph graph, boolean copyElements)
          Copy all vertices, edges, edge and vertex set of a graph, creating a new graph.
AbstractGraph(AbstractVertexSet abstractVertexSet, AbstractEdgeSet abstractEdgeSet)
          Constructor using a VertexSet and an EdgeSet.
 
Method Summary
 void addMissingVertices(AbstractVertexSet avs, AbstractEdgeSet aes)
          This function looks at the endpoints of every AbstractEdge from a given AbstractEdgeSet, check that they belong to a given AbstractVertexSet and if not add them.
 Iterator breadthFirstIterator(AbstractVertex root)
          Enables the traverse of a graph in a Breadth First way.
 boolean checkIntegrity()
          Integrity of the graph.
 AbstractGraph copyAbstractGraph()
          Copy all vertices, edges, edge and vertex set of a graph, creating a new graph.
static int countAllAbstractGraphs()
          Count all abstract graphs.
 Iterator depthFirstIterator(AbstractVertex root)
          Enables the traverse of a graph in a Depth First way.
 void free()
          Free memory when this object is linked.
 AbstractEdgeSet getAbstractEdgeSet()
          Returns the edge set of the graph.
 AbstractVertexSet getAbstractVertexSet()
          Returns the vertex set of the graph.
abstract  AbstractGraphFactory getFactory()
          Give the factory creating objects not abstract.
 AbstractGraph getSuperGraph()
          Returns the super set of the object if exists.
 boolean isSubGraph()
          Says if the object is a subset of an other.
 void replace(AbstractVertex vertex, AbstractGraph g)
          Not Implemented .
 void replace(AbstractVertex vertex, AbstractVertexSet vertexSet)
          Not Implemented .
 boolean setSuperGraph(AbstractGraph superGraph)
          Sets the supersets.
 Element toDOMTree(Element element)
          The method writes the current object in the DOMTree.
 String toString()
          Converts the Graph in string to be printed.
 
Methods inherited from class mascoptLib.abstractGraph.MascoptObject
copyValues, countAllObjects, deleteValue, deleteValue, existValue, existValue, getDOMTagHierarchy, getDOMTagName, getDoubleValue, getDoubleValue, getDouValue, getDouValue, getId, getIntegerValue, getIntegerValue, getIntValue, getIntValue, getName, getValue, getValue, getValueContexts, getValueDataType, getValueDataType, getValueEntries, notifyOnValueChange, removeAllValues, setDoubleValue, setDoubleValue, setDouValue, setDouValue, setIntegerValue, setIntegerValue, setIntValue, setIntValue, setName, setValue, setValue, setValue, setValue, setValue, setValue, toDOMTreeAsRef, update
 
Methods inherited from class mascoptLib.util.ObservableObject
addAddObserver, addRemoveObserver, addValueObserver, countAddObservers, countRemoveObservers, countValueObservers, deleteAddObserver, deleteAddObserver, deleteRemoveObserver, deleteRemoveObserver, deleteValueObserver, deleteValueObserver
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractGraph

public AbstractGraph()
Default Constructor of the graph.


AbstractGraph

public AbstractGraph(AbstractVertexSet abstractVertexSet,
                     AbstractEdgeSet abstractEdgeSet)
Constructor using a VertexSet and an EdgeSet.

Parameters:
abstractVertexSet - the vertex set to use when constructing the graph.
abstractEdgeSet - the edge set to use when constructing the graph.

AbstractGraph

public AbstractGraph(AbstractGraph superGraph)
Constructor of a subgraph. Constructs a graph with a sub vertex set and a sub edge set. The sub graph is empty when constructed.

Parameters:
superGraph - the graph used for the construction of the subgraph.

AbstractGraph

public AbstractGraph(AbstractGraph graph,
                     boolean copyElements)
Copy all vertices, edges, edge and vertex set of a graph, creating a new graph. Note that only the structure of the graph is duplicated. All the values stored with a context equal to this or with setValue are keep while this others are lost.

Parameters:
copyElements - indicates if new vertices and edges have to be duplicated. If false, the current vertices and edges of the graph are used and the supersets are preserved. On the contrary, if copyElements is true, new vertices and edges are created and you loose the values stored in it if the context is not this.
Method Detail

toString

public String toString()
Converts the Graph in string to be printed.


getFactory

public abstract AbstractGraphFactory getFactory()
Give the factory creating objects not abstract. As all the library is abstract, we need a factory that determines the type of graphs the user manipulates. Then the factory is able to create each type of object when necessary.


checkIntegrity

public boolean checkIntegrity()
Integrity of the graph. Default behavior: returns true.

Returns:
true if the integrity of the graph is true

getAbstractVertexSet

public AbstractVertexSet getAbstractVertexSet()
Returns the vertex set of the graph.

Returns:
the vertex set of the graph.

getAbstractEdgeSet

public AbstractEdgeSet getAbstractEdgeSet()
Returns the edge set of the graph.

Returns:
the edge set of the graph.

replace

public void replace(AbstractVertex vertex,
                    AbstractGraph g)
Not Implemented .


replace

public void replace(AbstractVertex vertex,
                    AbstractVertexSet vertexSet)
Not Implemented .


copyAbstractGraph

public AbstractGraph copyAbstractGraph()
Copy all vertices, edges, edge and vertex set of a graph, creating a new graph. Note that only the structure of the graph is duplicated. All the values stored with setValue are lost.

Returns:
the duplicated graph.

free

public void free()
Free memory when this object is linked. This method is necessary when an edge set is a sub set of an other edge set. As this sub set is listening to his father (for changes), it is not removed of memory when no one is pointing to it (because the father is still pointing to it). So, when the user does not use this object anymore, he must free it from his father. This method calls the free method on the edge set and vertex set of the graph.

Overrides:
free in class MascoptObject

countAllAbstractGraphs

public static int countAllAbstractGraphs()
Count all abstract graphs.

Returns:
the number of abstract graphs.

getSuperGraph

public AbstractGraph getSuperGraph()
Returns the super set of the object if exists.

Returns:
the super set of the object if exists.

isSubGraph

public boolean isSubGraph()
Says if the object is a subset of an other.

Returns:
true if the object is a subset of an other.

setSuperGraph

public boolean setSuperGraph(AbstractGraph superGraph)
Sets the supersets. Some checking is done. More precisely, it is checked that the AbstractVertexSet ( Resp. AbstractEdgeSet) of this is a subset of the AbstractVertexSet ( Resp. AbstractEdgeSet) of superSet.

NO CHECK IS DONE ABOUT AN EVENTUALLY ALREADY EXISTING SUPERGRAPH.

Parameters:
superGraph - the super graph to use for the graph.

breadthFirstIterator

public Iterator breadthFirstIterator(AbstractVertex root)
Enables the traverse of a graph in a Breadth First way. This method returns an Iterator, which will describe the vertices in a breadth first order.

Parameters:
root - the vertex from which we begin the search.
Returns:
an Iteratorobject.

depthFirstIterator

public Iterator depthFirstIterator(AbstractVertex root)
Enables the traverse of a graph in a Depth First way. This method returns an Iterator, which will describe the vertices in a depth first order.

Parameters:
root - the vertex from which we begin the search.
Returns:
an Iteratorobject.

addMissingVertices

public void addMissingVertices(AbstractVertexSet avs,
                               AbstractEdgeSet aes)
This function looks at the endpoints of every AbstractEdge from a given AbstractEdgeSet, check that they belong to a given AbstractVertexSet and if not add them.


toDOMTree

public Element toDOMTree(Element element)
The method writes the current object in the DOMTree.

Specified by:
toDOMTree in interface MascoptWritableInterface
Overrides:
toDOMTree in class MascoptObject
Parameters:
element - the current node of DOM document.