/**
- * Class representing the interaction graph of an application
+ * Class representing the application's graph
* @author Sébastien Miquée
*/
public class Graph implements Serializable
private ArrayList<GTask> graph ;
- private int nb_task ;
private int nb_dep_total ;
+ private int maxDep ;
/**
public Graph()
{
graph = new ArrayList<GTask>() ;
- nb_task = 0 ;
nb_dep_total = 0 ;
+ maxDep = 0 ;
}
*/
public int getNbGTask()
{
- return nb_task ;
+ return graph.size() ;
}
/**
- * Add a task in the interaction graph.
- * @param t Task to be add
+ * Add a task into the graph.
+ * @param _t Task to be add
*/
- public void addGTask( GTask t )
+ public void addGTask( GTask _t )
{
- if( t != null )
+ if( _t != null )
{
- graph.add( t.getNum(), t ) ;
- nb_dep_total += t.getNbDep() ;
- nb_task ++ ;
+ graph.add( _t.getNum(), _t ) ;
+ nb_dep_total += _t.getNbDep() ;
+
+ if ( _t.getNbDep() > maxDep )
+ {
+ maxDep = _t.getNbDep() ;
+ }
+ }
+ }
+
+
+ /**
+ * Add a list of tasks into the graph.
+ * @param _lt : Tasks list to be added
+ */
+ public void addGTasks( ArrayList<GTask> _lt )
+ {
+ if( _lt != null )
+ {
+ for( int i = 0 ; i < _lt.size() ; i++ )
+ {
+ graph.add( _lt.get( i ).getNum(), _lt.get( i ) ) ;
+ nb_dep_total += _lt.get( i ).getNbDep() ;
+
+ if ( _lt.get( i ).getNbDep() > maxDep )
+ {
+ maxDep = _lt.get( i ).getNbDep() ;
+ }
+ }
}
}
*/
public double getAverageDep()
{
- return nb_dep_total / nb_task ;
+ return nb_dep_total / graph.size() ;
+ }
+
+
+ /**
+ * Return the max amount of dependencies a task of the graphs can have.
+ * @return The maximum amount of dependencies
+ */
+ public int getMaxDep()
+ {
+ return maxDep ;
}
/**
- * Print the graph in a text version.
+ * Print the graph in a comprehensible text version.
*/
public void print()
{
System.out.println();
System.out.println( "\t=> Composition of interaction graph:\n" ) ;
- for( int i = 0 ; i < nb_task ; i++ )
+ for( int i = 0 ; i < graph.size() ; i++ )
{
System.out.println( "\t\tTask \""+ graph.get(i).getNum() +"\" => " + graph.get(i).printDep() ) ;
}